DECLARE tables_cursor CURSOR
FOR
SELECT top 100 name FROM sysobjects WHERE type = 'U' order by name
OPEN tables_cursor
DECLARE @tablename varchar(30), @quote char(1)
SELECT @quote = ''
FETCH NEXT FROM tables_cursor INTO @tablename
WHILE (@@fetch_status <> -1)
BEGIN
EXEC ('Select count(*) as ''' + @tablename + ''' from '+ @tablename)
FETCH NEXT FROM tables_cursor INTO @tablename
END
DEALLOCATE tables_cursor
浙公网安备 33010602011771号