Back to OIM Explorer

dbo.QBM_FSQTableDef

Scalar FunctionSQL_SCALAR_FUNCTIONSandbox DB

Scalar Function.

Source: sandbox-db sys.sql_modules

Source size: 1.126 characters

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_FGIDiskStoreTarget source text reference
  • references source dbo.QBM_FSQColumDef source text reference
  • references source dbo.QBM_FSQIndexDef source text reference
  • references source dbo.QBM_FSQPrimaryKeyDef source text reference
  • references source dbo.QBM_FSQPrimaryKeyDef_S source text reference

Complete Source

SQL48 lines
1CREATE FUNCTION dbo.QBM_FSQTableDef(2  @TableName nvarchar(64)3) RETURNS nvarchar(max4)5AS6BEGIN7  DECLARE @erg nvarchar(max) = ''8  DECLARE @durability varchar(64) = ''9  DECLARE @ismem BIT = 010  IF EXISTS(11    SELECT TOP 1 112    FROM sys.tables t13    WITH(readpast)14  WHERE15    t.name = @TableName AND t.is_memory_optimized = 1)16  BEGIN17    SELECT @ismem = 118  END19  IF @ismem = 120  BEGIN21    SELECT TOP 1 @durability = t.durability_desc22    FROM sys.tables t23      WITH(readpast)24    WHERE25      t.name = @TableName26  END27  SELECT28    @erg = N 'Create Table ' + @TableName + N '(' + nchar(13) + nchar(10) + dbo.QBM_FSQColumDef(@TableName,29    '%') + nchar(13) + nchar(10) + + CASE @ismem30    WHEN 1 THEN31    dbo.QBM_FSQIndexDef(@TableName,32    '%')33  ELSE ''34  END + nchar(9) + isnull(dbo.QBM_FSQPrimaryKeyDef_S(@TableName),35  '<PKDef not found>') + nchar(13) + nchar(10) + nchar(9) + N ')' + nchar(13) + nchar(10)36  IF @ismem = 137  BEGIN38    SELECT39      @erg = @erg + nchar(9) + 'with (MEMORY' + '_' + 'OPTIMIZED = on, DURABILITY = ' + @durability + ')'40  END41  ELSE42  BEGIN43    SELECT44      @erg = @erg + nchar(9) + 'on "' + isnull(dbo.QBM_FGIDiskStoreTarget(@TableName),45      '<DiskStore not found>') + '"'46  END47  RETURN(@erg)48END
Open raw exported source
SQL ยท Raw9 lines
1   create   function dbo.QBM_FSQTableDef (@TableName nvarchar(64)) returns nvarchar(max) as begin declare @erg nvarchar(max) = '' declare @durability2 varchar(64) = '' declare @ismem bit = 0 if exists (select top 1 1 from sys.tables t with (readpast) where t.name = @TableName and t.is_memory_optimized3 = 1 ) begin select @ismem = 1 end if @ismem = 1 begin select top 1 @durability = t.durability_desc from sys.tables t with (readpast) where t.name = @TableName4 end select @erg = N'Create Table ' + @TableName + N'(' + nchar(13) + nchar(10) + dbo.QBM_FSQColumDef(@TableName, '%') + nchar(13) + nchar(10) + + case5 @ismem when 1 then dbo.QBM_FSQIndexDef(@TableName, '%') else '' end + nchar(9) + isnull(dbo.QBM_FSQPrimaryKeyDef_S(@TableName ), '<PKDef not found>') 6+ nchar(13) + nchar(10) + nchar(9) + N')' + nchar(13) + nchar(10) if @ismem = 1 begin select @erg = @erg + nchar(9) + 'with (MEMORY' + '_' + 'OPTIMIZED = on, DURABILITY = '7 + @durability + ')' end else begin select @erg = @erg + nchar(9) + 'on "' + isnull(dbo.QBM_FGIDiskStoreTarget(@TableName), '<DiskStore not found>') + 8'"' end return(@erg) end 9