dbo.QBM_FCVStringReplace
Scalar FunctionSQL_SCALAR_FUNCTIONSandbox DB
Interpretation
- Database function. Usually supports views, validation, or calculated predicates; look at referenced-by entries for callers.
Relations
- No extracted relations.
Typed Edges
- No typed edges extracted for this source.
References
- No direct source references extracted.
Referenced By
- No direct source references extracted.
Complete Source
1CREATE FUNCTION dbo.QBM_FCVStringReplace(2 @In nvarchar(max),3 @Replacements dbo.QBM_YParameterList READONLY,4 @CaseSensitive BIT = 05) RETURNS nvarchar(max6)7 WITH SCHEMABINDING8AS9BEGIN10 DECLARE @erg nvarchar(max)11 DECLARE @Parameter1 varchar(138),12 @ContentShort nvarchar(400),13 @HasContentFull BIT,14 @ContentFull nvarchar(max)15 DECLARE @ElementBuffer dbo.QBM_YCursorBuffer16 DECLARE @ElementCount int17 DECLARE @ElementIndex int18 SELECT @erg = @in19 INSERT INTO @ElementBuffer(ObjectKey1,20 ContentShort,21 Bit1,22 ContentFull)23 SELECT24 Parameter1,25 ContentShort,26 HasContentFull,27 ContentFull28 FROM @Replacements29 SELECT @ElementCount = @@ROWCOUNT30 SELECT @ElementIndex = 131 WHILE @ElementIndex <= @ElementCount32 BEGIN33 SELECT34 TOP 1 @Parameter1 = bu.ObjectKey1,35 @ContentShort = bu.ContentShort,36 @HasContentFull = bu.Bit1,37 @ContentFull = bu.ContentFull38 FROM @ElementBuffer bu39 WHERE40 bu.ElementIndex = @ElementIndex41 IF @HasContentFull = 042 BEGIN43 IF @CaseSensitive = 144 BEGIN45 SELECT46 @erg = replace(@erg,47 @Parameter1,48 @ContentShort collate SQL_Latin1_General_CP1_CS_AS)49 END50 ELSE51 BEGIN52 SELECT53 @erg = replace(@erg,54 @Parameter1,55 @ContentShort)56 END57 END58 ELSE59 BEGIN60 IF @CaseSensitive = 161 BEGIN62 SELECT63 @erg = replace(@erg,64 @Parameter1,65 @ContentFull collate SQL_Latin1_General_CP1_CS_AS)66 END67 ELSE68 BEGIN69 SELECT70 @erg = replace(@erg,71 @Parameter1,72 @ContentFull)73 END74 END75 SELECT @ElementIndex += 176 END77 ende:78 RETURN(@erg)79END
Open raw exported source
1 create function dbo.QBM_FCVStringReplace ( @In nvarchar(max) , @Replacements dbo.QBM_YParameterList readonly , @CaseSensitive bit = 0 ) returns2 nvarchar(max) with SCHEMABINDING as begin declare @erg nvarchar(max) declare @Parameter1 varchar(138) , @ContentShort nvarchar(400) , @HasContentFull 3bit , @ContentFull nvarchar(max) declare @ElementBuffer dbo.QBM_YCursorBuffer declare @ElementCount int declare @ElementIndex int select @erg = @in insert4 into @ElementBuffer (ObjectKey1, ContentShort, Bit1, ContentFull) select Parameter1, ContentShort, HasContentFull, ContentFull from @Replacements select5 @ElementCount = @@ROWCOUNT select @ElementIndex = 1 while @ElementIndex <= @ElementCount begin select top 1 @Parameter1 = bu.ObjectKey1 , @ContentShort6 = bu.ContentShort , @HasContentFull = bu.Bit1 , @ContentFull = bu.ContentFull from @ElementBuffer bu where bu.ElementIndex = @ElementIndex if @HasContentFull7 = 0 begin if @CaseSensitive = 1 begin select @erg = replace(@erg, @Parameter1, @ContentShort collate SQL_Latin1_General_CP1_CS_AS ) end else begin select8 @erg = replace(@erg, @Parameter1, @ContentShort) end end else begin if @CaseSensitive = 1 begin select @erg = replace(@erg, @Parameter1, @ContentFull 9collate SQL_Latin1_General_CP1_CS_AS ) end else begin select @erg = replace(@erg, @Parameter1, @ContentFull) end end select @ElementIndex += 1 end ende:10 return(@erg) end 11