SQl List of View and Count of Rows in Views
hi experts,
i working on sql server 2008,need sql query display name of views and count of rows in each view in database
any help?
try this:
create procedure dbo.viewsrowcount as begin create table #temprowcount ( name varchar(100), row_count int ) declare @sql varchar(max) set @sql = '' select @sql = @sql + 'insert #temprowcount select ''' + name + ''', count(*) ' + quotename(name) + char(13) from sys.objects where type = 'v' exec (@sql) select name, row_count from #temprowcount end
once procedure created; can use as:
exec dbo.viewsrowcount
- vishal
SQL Server > SQL Server Database Engine
Comments
Post a Comment