Wednesday, July 9, 2014

SQL FUNCTION - GetAllTablesRowCounts( )

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:        tcarter
-- Create date: 7/9/2014
-- Description:    ALL TABLES SIZES
-- =============================================
CREATE FUNCTION [dbo].[GetAllTablesRowCounts]
(    
    @DBNAME VARCHAR(50)
)
RETURNS TABLE
AS
RETURN
(
 
    SELECT TOP 1000 OBJECT_NAME(object_id)tablename,* from sys.partitions where object_id>100 and index_id=1 order by rows desc
)

GO


No comments:

Post a Comment