Back to OIM Explorer

dbo.QBM_FGITableCountAll

Scalar FunctionSQL_SCALAR_FUNCTIONSandbox DB

Scalar Function.

Source: sandbox-db sys.sql_modules

Source size: 510 characters

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

SQL25 lines
1CREATE FUNCTION dbo.QBM_FGITableCountAll(2  @TableName nvarchar(32)3) RETURNS bigint4AS5BEGIN6  DECLARE @erg bigint = -17  SELECT TOP 1 @erg = y.CountItems8  FROM(9  SELECT10    sum(x.rows) AS CountItems,11    x.TableName12  FROM(13  SELECT14    t.name AS TableName, avg(p.rows) AS rows, p.partition_number15  FROM sys.tables t16    WITH(readpast)17  JOIN sys.partitions p18    WITH(readpast)19    ON t.object_id = p.object_id20  WHERE21    t.name = @TableName22  GROUP BY t.name, p.partition_number) AS x23  GROUP BY x.TableName) AS y24  RETURN(@erg)25END
Open raw exported source
SQL ยท Raw5 lines
1    create   function dbo.QBM_FGITableCountAll( @TableName nvarchar(32) ) returns bigint  as begin declare @erg bigint = -1 select top 1 @erg = 2y.CountItems from ( select sum(x.rows) as CountItems , x.TableName from ( select t.name as TableName, avg(p.rows) as rows , p.partition_number from sys.tables3 t with (readpast) join sys.partitions p with (readpast) on t.object_id = p.object_id where t.name = @TableName group by t.name, p.partition_number ) as4 x group by x.TableName ) as y return(@erg) end 5