dbo.QBM_FSQCVBufferToColumn
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
- references source dbo.QBM_FCVStringToBigInt source text reference
- references source dbo.QBM_FCVStringToBinary source text reference
- references source dbo.QBM_FCVStringToBit source text reference
- references source dbo.QBM_FCVStringToDatetime source text reference
- references source dbo.QBM_FCVStringToDatetime_BU source text reference
- references source dbo.QBM_FCVStringToFloat source text reference
- references source dbo.QBM_FCVStringToInt source text reference
- references source dbo.QBM_FGIColumnDataLen source text reference
- references source dbo.QBM_FGIColumnDataType source text reference
Complete Source
1CREATE FUNCTION dbo.QBM_FSQCVBufferToColumn(2 @TableName varchar(30),3 @columnname varchar(30),4 @BufferTableName varchar(64),5 @IsNullOption BIT6) RETURNS nvarchar(max7)8AS9BEGIN10 DECLARE @erg nvarchar(max)11 DECLARE @datatype nvarchar(64)12 DECLARE @DataMaxLen int13 SELECT14 @datatype = dbo.QBM_FGIColumnDataType(@TableName,15 @columnname)16 SELECT17 @DataMaxLen = dbo.QBM_FGIColumnDataLen(@TableName,18 @columnname)19 IF @datatype = 'int'20 BEGIN21 SELECT22 @erg = CONCAT('dbo.QBM_FCVStringToInt(',23 @BufferTableName,24 '.ContentShort, 0)')25 GOTO ende26 END27 IF @datatype = 'bigint'28 BEGIN29 SELECT30 @erg = CONCAT('dbo.QBM_FCVStringToBigInt(',31 @BufferTableName,32 '.ContentShort, 0)')33 GOTO ende34 END35 IF @datatype = 'datetime'36 BEGIN37 IF @IsNullOption = 038 BEGIN39 SELECT40 @erg = CONCAT('dbo.QBM_FCVStringToDatetime_BU(',41 @BufferTableName,42 '.ContentShort)')43 END44 ELSE45 BEGIN46 SELECT47 @erg = CONCAT(' isnull(',48 'dbo.QBM_FCVStringToDatetime_BU(',49 @BufferTableName,50 '.ContentShort)',51 ', ''1800-01-01'' ) ')52 END53 GOTO ende54 END55 IF @datatype = 'Float'56 BEGIN57 SELECT58 @erg = CONCAT('dbo.QBM_FCVStringToFloat(',59 @BufferTableName,60 '.ContentShort, 0.0)')61 GOTO ende62 END63 IF @datatype = 'Bit'64 BEGIN65 SELECT66 @erg = CONCAT('dbo.QBM_FCVStringToBit(',67 @BufferTableName,68 '.ContentShort)')69 GOTO ende70 END71 IF @datatype = 'varbinary'72 BEGIN73 IF @DataMaxLen <= 19874 BEGIN75 IF @IsNullOption = 076 BEGIN77 SELECT78 @erg = CONCAT('dbo.QBM_FCVStringToBinary(',79 @BufferTableName,80 '.ContentShort)')81 END82 ELSE83 BEGIN84 SELECT85 @erg = CONCAT('isnull(dbo.QBM_FCVStringToBinary(',86 @BufferTableName,87 '.ContentShort), 0x0)')88 END89 END90 ELSE91 BEGIN92 IF @IsNullOption = 093 BEGIN94 SELECT95 @erg = CONCAT('96case 97 when ',98 @BufferTableName,99 '.HasContentFull = 1 then dbo.QBM_FCVStringToBinary(',100 @BufferTableName,101 '.ContentFull)102 else dbo.QBM_FCVStringToBinary(',103 @BufferTableName,104 '.ContentShort)105end')106 END107 ELSE108 BEGIN109 SELECT110 @erg = CONCAT('111case 112 when ',113 @BufferTableName,114 '.HasContentFull = 1 then dbo.QBM_FCVStringToBinary(',115 @BufferTableName,116 '.ContentFull)117 else isnull(dbo.QBM_FCVStringToBinary(',118 @BufferTableName,119 '.ContentShort), 0x0)120end')121 END122 END123 GOTO ende124 END125 IF @datatype IN('char',126 'nchar',127 'varchar',128 'nvarchar')129 BEGIN130 IF @DataMaxLen <= 400131 BEGIN132 IF @isNullOption = 0133 BEGIN134 SELECT135 @erg = CONCAT('',136 @BufferTableName,137 '.ContentShort')138 END139 ELSE140 BEGIN141 IF @datatype IN('nvarchar',142 'nchar')143 BEGIN144 SELECT145 @erg = CONCAT('isnull(',146 @BufferTableName,147 '.ContentShort, N'''')')148 END149 ELSE150 BEGIN151 SELECT152 @erg = CONCAT('isnull(',153 @BufferTableName,154 '.ContentShort, '''')')155 END156 END157 END158 ELSE159 BEGIN160 IF @isNullOption = 0161 BEGIN162 SELECT163 @erg = CONCAT('164case 165 when ',166 @BufferTableName,167 '.HasContentFull = 1 then ',168 @BufferTableName,169 '.ContentFull170 else ',171 @BufferTableName,172 '.ContentShort173end')174 END175 ELSE176 BEGIN177 IF @datatype IN('nvarchar',178 'nchar')179 BEGIN180 SELECT181 @erg = CONCAT('182case 183 when ',184 @BufferTableName,185 '.HasContentFull = 1 then isnull(',186 @BufferTableName,187 '.ContentFull, N'''')188 else isnull(',189 @BufferTableName,190 '.ContentShort, N'''')191end')192 END193 ELSE194 BEGIN195 SELECT196 @erg = CONCAT('197case 198 when ',199 @BufferTableName,200 '.HasContentFull = 1 then isnull(',201 @BufferTableName,202 '.ContentFull, '''')203 else isnull(',204 @BufferTableName,205 '.ContentShort, '''')206end')207 END208 END209 END210 GOTO ende211 END212 SELECT @erg = ' message this_must_be_an_invalid_datatype' ende:213 RETURN(@erg)214END
Open raw exported source
1 create function dbo.QBM_FSQCVBufferToColumn (@TableName varchar(30) , @columnname varchar(30) , @BufferTableName varchar(64) , @IsNullOption2 bit ) returns nvarchar(max) as begin declare @erg nvarchar(max) declare @datatype nvarchar(64) declare @DataMaxLen int select @datatype = dbo.QBM_FGIColumnDataType3(@TableName , @columnname) select @DataMaxLen = dbo.QBM_FGIColumnDataLen(@TableName , @columnname) if @datatype = 'int' begin select @erg = concat('dbo.QBM_FCVStringToInt('4 , @BufferTableName , '.ContentShort, 0)') goto ende end if @datatype = 'bigint' begin select @erg = concat('dbo.QBM_FCVStringToBigInt(' , @BufferTableName5 , '.ContentShort, 0)') goto ende end if @datatype = 'datetime' begin if @IsNullOption = 0 begin select @erg = concat('dbo.QBM_FCVStringToDatetime_BU('6 , @BufferTableName , '.ContentShort)') end else begin select @erg = concat(' isnull(' , 'dbo.QBM_FCVStringToDatetime_BU(' , @BufferTableName , '.ContentShort)'7 , ', ''1800-01-01'' ) ' ) end goto ende end if @datatype = 'Float' begin select @erg = concat('dbo.QBM_FCVStringToFloat(' , @BufferTableName , '.ContentShort, 0.0)'8) goto ende end if @datatype = 'Bit' begin select @erg = concat('dbo.QBM_FCVStringToBit(' , @BufferTableName , '.ContentShort)') goto ende end if @datatype9 = 'varbinary' begin if @DataMaxLen <= 198 begin if @IsNullOption = 0 begin select @erg = concat('dbo.QBM_FCVStringToBinary(' , @BufferTableName , '.ContentShort)'10) end else begin select @erg = concat('isnull(dbo.QBM_FCVStringToBinary(' , @BufferTableName , '.ContentShort), 0x0)') end end else begin if @IsNullOption11 = 0 begin select @erg = concat('12case 13 when ' , @BufferTableName , '.HasContentFull = 1 then dbo.QBM_FCVStringToBinary(' , @BufferTableName , '.ContentFull)14 else dbo.QBM_FCVStringToBinary('15 , @BufferTableName , '.ContentShort)16end' ) end else begin select @erg = concat('17case 18 when ' , @BufferTableName , '.HasContentFull = 1 then dbo.QBM_FCVStringToBinary('19 , @BufferTableName , '.ContentFull)20 else isnull(dbo.QBM_FCVStringToBinary(' , @BufferTableName , '.ContentShort), 0x0)21end' ) end end goto ende end22 if @datatype in( 'char' , 'nchar', 'varchar', 'nvarchar') begin if @DataMaxLen <= 400 begin if @isNullOption = 0 begin select @erg = concat('' , @BufferTableName23 , '.ContentShort') end else begin if @datatype in( 'nvarchar' , 'nchar') begin select @erg = concat('isnull(' , @BufferTableName , '.ContentShort, N'''')'24) end else begin select @erg = concat('isnull(' , @BufferTableName , '.ContentShort, '''')') end end end else begin if @isNullOption = 0 begin select 25@erg = concat('26case 27 when ' , @BufferTableName , '.HasContentFull = 1 then ' , @BufferTableName , '.ContentFull28 else ' , @BufferTableName , '.ContentShort29end'30 ) end else begin if @datatype in( 'nvarchar' , 'nchar') begin select @erg = concat('31case 32 when ' , @BufferTableName , '.HasContentFull = 1 then isnull('33 , @BufferTableName , '.ContentFull, N'''')34 else isnull(' , @BufferTableName , '.ContentShort, N'''')35end' ) end else begin select @erg = concat('36case 37 when '38 , @BufferTableName , '.HasContentFull = 1 then isnull(' , @BufferTableName , '.ContentFull, '''')39 else isnull(' , @BufferTableName , '.ContentShort, '''')40end'41 ) end end end goto ende end select @erg = ' message this_must_be_an_invalid_datatype' ende: return(@erg) end 42