22,209
社区成员
发帖
与我相关
我的任务
分享
declare @sql nvarchar(1000)
DECLARE @ii INT=0
declare c1 cursor FOR
select 'select @ii=count(*) from '+name from sysobjects
where xtype='U' and name like 'formmain_%' and (name not in ('formmain_0388','formmain_0795','formmain_0115'))
GROUP BY name
HAVING count(*)<>0
open c1
fetch next from c1 into @sql
while @@fetch_status=0
begin
exec(@sql)
PRINT @ii+@sql
fetch next from c1 into @sql
end
close c1
deallocate c1
EXEC sp_msforeachtable 'select ''?'' as TableName, count(0) from ? '
,@whereand='and Schema_Id=Schema_id(''DBO'') and o.Name like ''formmain_%'' and (o.name not in (''formmain_0388'',''formmain_0795'',''formmain_0115''))'
DECLARE @sql NVARCHAR(1000)
DECLARE @ii INT= 0
DECLARE c1 CURSOR
FOR
SELECT 'select @ii=count(*) from ' + name
FROM sysobjects
WHERE xtype = 'U'
AND name LIKE 'formmain_%'
AND ( name NOT IN ( 'formmain_0388', 'formmain_0795',
'formmain_0115' ) )
GROUP BY name
HAVING COUNT(*) <> 0
OPEN c1
FETCH NEXT FROM c1 INTO @sql
WHILE @@fetch_status = 0
BEGIN
EXEC sp_executesql @sql, N'@ii int out', @ii OUT
PRINT RTRIM(@ii) + @sql
FETCH NEXT FROM c1 INTO @sql
END
CLOSE c1
DEALLOCATE c1
DECLARE @sql NVARCHAR(1000)
DECLARE @ii INT= 0
DECLARE c1 CURSOR
FOR
SELECT 'select @ii=count(*) from ' + name
FROM sysobjects
WHERE xtype = 'U'
GROUP BY name
HAVING COUNT(*) <> 0
OPEN c1
FETCH NEXT FROM c1 INTO @sql
WHILE @@fetch_status = 0
BEGIN
EXEC sp_executesql @sql, N'@ii int out', @ii OUT
PRINT RTRIM(@ii) + @sql
FETCH NEXT FROM c1 INTO @sql
END
CLOSE c1
DEALLOCATE c1
DECLARE @sql NVARCHAR(1000)
DECLARE @ii INT= 0
DECLARE c1 CURSOR
FOR
SELECT 'select @ii=count(*) from ' + name
FROM sysobjects
WHERE xtype = 'U'
AND name LIKE 'formmain_%'
AND ( name NOT IN ( 'formmain_0388', 'formmain_0795',
'formmain_0115' ) )
GROUP BY name
HAVING COUNT(*) <> 0
OPEN c1
FETCH NEXT FROM c1 INTO @sql
WHILE @@fetch_status = 0
BEGIN
EXEC sp_executesql @sql, N'@ii int out', @ii OUT
PRINT @ii + @sql
FETCH NEXT FROM c1 INTO @sql
END
CLOSE c1
DEALLOCATE c1