dbo.QBM_FSQTableJoin
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
Complete Source
1CREATE FUNCTION dbo.QBM_FSQTableJoin(2 @TableName nvarchar(64),3 @LeftSynonym nvarchar(32),4 @RightSynonym nvarchar(32)5) RETURNS nvarchar(max6)7AS8BEGIN9 DECLARE @erg nvarchar(max)10 DECLARE @Pkcol1 nvarchar(64)11 DECLARE @Pkcol2 nvarchar(64)12 SELECT @Pkcol1 = NULL13 SELECT @Pkcol2 = NULL14 IF EXISTS(15 SELECT TOP 1 116 FROM dbo.DialogTable t17 WITH(readpast)18 JOIN dbo.DialogColumn c19 WITH(readpast)20 ON t.UID_DialogTable = c.UID_DialogTable AND c.ColumnName = 'XObjectKey' AND t.TableName = @TableName21 JOIN dbo.DialogColumn cx22 WITH(readpast)23 ON cx.UID_DialogTable = t.UID_DialogTable AND cx.ColumnName = 'XOrigin'24 WHERE25 (t.IsMAllTable = 1 OR t.isMNTable = 1))26 BEGIN27 SELECT @pkcol1 = 'XObjectKey'28 END29 ELSE30 BEGIN31 SELECT32 TOP 1 @pkcol1 = isnull(t.PKName1,33 ''),34 @Pkcol2 = isnull(t.PKName2,35 '')36 FROM dbo.DialogTable t37 WITH(readpast)38 WHERE39 t.TableName = @TableName40 END41 SELECT42 @erg = CONCAT(N ' ',43 @LeftSynonym,44 '.',45 @Pkcol1,46 N ' = ',47 @RightSynonym,48 '.',49 @Pkcol1)50 IF @Pkcol2 > ' '51 BEGIN52 SELECT53 @erg = CONCAT(@erg,54 N ' and ',55 @LeftSynonym,56 '.',57 @Pkcol2,58 N ' = ',59 @RightSynonym,60 '.',61 @Pkcol2)62 END63 RETURN(@erg)64END
Open raw exported source
1 create function dbo.QBM_FSQTableJoin (@TableName nvarchar(64) , @LeftSynonym nvarchar(32) , @RightSynonym nvarchar(32) ) returns nvarchar(max2) as begin declare @erg nvarchar(max) declare @Pkcol1 nvarchar(64) declare @Pkcol2 nvarchar(64) select @Pkcol1 = null select @Pkcol2 = null if exists3 (select top 1 1 from dbo.DialogTable t with (readpast) join dbo.DialogColumn c with (readpast) on t.UID_DialogTable = c.UID_DialogTable and c.ColumnName4 = 'XObjectKey' and t.TableName = @TableName join dbo.DialogColumn cx with (readpast) on cx.UID_DialogTable = t.UID_DialogTable and cx.ColumnName = 'XOrigin'5 where (t.IsMAllTable = 1 or t.isMNTable = 1) ) begin select @pkcol1 = 'XObjectKey' end else begin select top 1 @pkcol1 = isnull(t.PKName1, '') , @Pkcol26 = isnull(t.PKName2, '') from dbo.DialogTable t with (readpast) where t.TableName = @TableName end select @erg = concat(N' ' , @LeftSynonym , '.' , @Pkcol17 , N' = ' , @RightSynonym , '.' , @Pkcol1) if @Pkcol2 > ' ' begin select @erg = concat(@erg , N' and ' , @LeftSynonym , '.' , @Pkcol2 , N' = ' , @RightSynonym8 , '.' , @Pkcol2) end return(@erg) end 9