example t-sql: count records of multible tables

declare @tablename varchar(250)

declare @rows int
declare
cC cursor local for
select name from sysobjects
where type = ‘U’
and name like ‘%Artikel%’
order by name

OPEN
cC
IF @@Cursor_Rows <> 0
BEGIN

FETCH NEXT FROM cC into @tablename
WHILE (@@Fetch_Status =0)
BEGIN

SELECT @rows=rows FROM sysindexes WHERE id = OBJECT_ID(@tablename) AND indid < 2
print @tablename + ‘;’ + ltrim(str(@rows))

FETCH NEXT FROM cC into @tablename
END

END

CLOSE cC
DEALLOCATE cC

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s