Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting row count as part of DB design info
Message
From
05/02/2008 10:00:43
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01289085
Message ID:
01289522
Views:
16
>>I tried the following, but I think the the sp still looks at the tables from the current DB. I can insert the results from the original version into the temp table, then into another table. I was just trying to find a way to do it in one command.
>>
>>use MyDesignDB
>>go
>>create table tRowCount (tablename varchar(128), rowcnt int)
>>exec sp_MSforeachtable
>>   'insert into tRowCount select 'MyTestDB.' + ''?'', count(*) from 'MyTestDB.' + ?'
>>select * from tRowCount
>>    order by rowcnt, tablename
>>
>
>Looks like you would not be able to do it. In my tries I was getting
>
>Could not find server 'Database name' in sysservers. Execute sp_addlinkedserver to add the server to sysservers.

Doing it with two commands is fine. I still have an execute time of 00.00.00. There are less than 200 records. I was just looking for a little more elegance.

BTW, I got the same execute time with all three methods (dynamic, cursor, and sp). I think there is not enough data here to tax the system.
Thank You

Rollin Burr

Politicians and diapers have one thing in common. They should both be changed regularly, and for the same reason.
Previous
Reply
Map
View

Click here to load this message in the networking platform