扩展我的正则表达式

时间:2014-12-01 10:53:17

标签: sql-server regex

我需要ms sql中正则表达式的帮助 这是我的代码

SET @sql='MERGE [WarehouseMgmt].[DimReportServerUserEntries] AS Target
    USING( 
              SELECT REX.[Value],RS.LogEntryId FROM '+@server+'.[dbo].[ExecutionLogStorage] RS 
              CROSS APPLY [WarehouseMgmt].RegExpMatches(RS.[Parameters], ''(?<=User=).+?(?=&)'') REX
             -- WHERE RS.LogEntryId > @LastId
          ) AS Source
    ON Source.LogEntryId=Target.SourceOrigId
    WHEN NOT MATCHED BY TARGET THEN
        INSERT 
        (
            [UserName],
            [SourceOrigId]

        )
        VALUES 
        (
            Source.[Value],
            Source.[LogEntryId]
        )

在ReportServer中。[dbo]。[ExecutionLogStorage]表是[Parameter]字段,里面的参数我有这个:

&User:isnull=true& but there also can be &User=somename& , or thare can be no UserName at all

对于&amp; User = somename&amp;我在我的reg中处理。表达

我想更新我的表[WarehouseMgmt]。[DimReportServerUserEntries]所以如果UserName是&amp; User:isnull = true&amp; UserName =&lt;'UNKNOWN'&gt;和SourceOrigId = -1

0 个答案:

没有答案