Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Change DbOwner

Author  Topic 

OBINNA_EKE
Posting Yak Master

234 Posts

Posted - 2006-04-11 : 09:41:46
How do I loop through a database and display all the table name in it

then use

SP_ChangeObjectOwner "TABLE_NAME","dbo"

where table_owner is OBI

In a nut shell, how do I loop through a database and isplay name ?

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-04-11 : 09:49:49
using Select * From Master..Sysdatabases you will get list of all the databases attached on the server.

using Select * From Information_Schema.Tables you will get list of all the tables of the database.

using cursor and dynamic sql you can loop through all the tables and run the procedure.

If Debugging is the process of removing Bugs then i Guess programming should be process of Adding them.
Go to Top of Page
   

- Advertisement -