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

sqlandme.com



SQL Server  >  SQL Server Database Engine



Comments

Popular posts from this blog

Conditional formatting a graph vertical axis in SSRS 2012 charts

Register with Power BI failed

SQL server replication error Cannot find the dbo or user defined function........