dbo.QBM_FCVStringToBinary
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.
Complete Source
1CREATE FUNCTION dbo.QBM_FCVStringToBinary(2 @in varchar(max)3) RETURNS varbinary(max4)5 WITH SCHEMABINDING6AS7BEGIN8 DECLARE @erg varbinary(max) = NULL9 IF isnull(@in,10 N '') = N ''11 BEGIN12 RETURN(@erg)13 END14 ELSE15 BEGIN16 IF17 LEFT(@in,18 2) = '0x'19 BEGIN20 IF len(@in) % 2 > 021 BEGIN22 SELECT23 @erg = try_convert(varbinary(max),24 @in + '0',25 1)26 END27 ELSE28 BEGIN29 SELECT30 @erg = try_convert(varbinary(max),31 @in,32 1)33 END34 END35 ELSE36 BEGIN37 IF len(@in) % 4 > 038 BEGIN39 SELECT @erg = NULL40 END41 ELSE42 BEGIN43 SELECT44 @erg = try_convert(xml,45 N '') .value('xs:base64Binary(sql:variable("@in"))',46 'varbinary(max)')47 END48 END49 END50 EndLabel:51 RETURN(@erg)52END
Open raw exported source
1 create function dbo.QBM_FCVStringToBinary ( @in varchar(max) ) returns varbinary(max) with SCHEMABINDING as begin declare @erg varbinary(max2) = null if isnull(@in, N'') = N'' begin return(@erg) end else begin if left(@in, 2) = '0x' begin if len(@in) % 2 > 0 begin select @erg = try_convert3(varbinary(max), @in + '0' , 1) end else begin select @erg = try_convert(varbinary(max), @in , 1) end end else begin if len(@in) % 4 > 0 begin select4 @erg = null end else begin select @erg = try_convert(xml, N'').value('xs:base64Binary(sql:variable("@in"))', 'varbinary(max)') end end end EndLabel: return5(@erg) end 6