CREATE TABLE ##temp(
  id int identity(1,1),
   TbName varchar(500)
  )

   CREATE TABLE ##temp1(
  id int identity(1,1),
   TbName varchar(500)
  )

  go 
insert into ##temp 
select t.name as TbName from  SYS.tables t

 go
 
  declare @n int 
  set @n=1
  declare @tempid  varchar(500) 
  set @tempid=0
  declare @rows int
  select @rows=count(*) from ##temp  
  while @n <= @rows 
  begin
        
		declare @tempid1 varchar(500) 
		declare @sql varchar(500) 
		declare @TbName varchar(500) 
	 	select  @TbName=TbName from ##temp  where id = @n
		set @sql = 'select count(*) from '+ @TbName;
		EXEC (@sql)--查询本表数据条数
		select @TbName--查询本表表名
		set @n = @n + 1
  end 
 --Drop TABLE ##temp
--Drop TABLE ##temp1

  

相关文章:

  • 2021-09-29
  • 2021-06-24
  • 2021-10-29
  • 2021-10-29
  • 2021-11-17
  • 2021-11-29
  • 2021-09-29
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-03-06
  • 2021-11-02
  • 2021-09-21
  • 2022-12-23
  • 2021-09-08
相关资源
相似解决方案