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.
| Author |
Topic |
|
olivia2008
Starting Member
3 Posts |
Posted - 2008-06-12 : 03:41:22
|
| I have 3 database saydb1db2db3I need to setup a script to read all the table names in the database above and then query the database to find the list of Stored Procedure using each table.(SQL Server) |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2008-06-12 : 03:56:31
|
To get a list of user tables in each database, run:select * from sys.objects where type = 'U' |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-12 : 04:02:08
|
| EXEC sp_msforeachdb to execute script for each dbuse SELECT * FROM INFORMATION_SCHEMA.TABLES to get table names in each dbuse sp_depends TableNAme to get dependent stored procedures for each table. |
 |
|
|
olivia2008
Starting Member
3 Posts |
Posted - 2008-06-12 : 04:19:23
|
| CANT IT BE DONE IN A SINGLE STORED PROCEDURE USING CURSOR? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-12 : 04:22:05
|
quote: Originally posted by olivia2008 CANT IT BE DONE IN A SINGLE STORED PROCEDURE USING CURSOR?
You can. Put the statements provided inside a stored procedure. You might require a table to put results of SELECT query and then need to loop on it using while loop and execute sp_depends from within the loop. |
 |
|
|
olivia2008
Starting Member
3 Posts |
Posted - 2008-06-12 : 04:30:09
|
quote: You can. Put the statements provided inside a stored procedure. You might require a table to put results of SELECT query and then need to loop on it using while loop and execute sp_depends from within the loop.
WOULD BE THANKFUL TO YOU IF YOU CAN DEMONSTRATE WITH EXAMPLE.I AM VERY MUCH NEW TO SQL SERVER.YOUR HELP WILL BE HIGHLY APPRICIATED |
 |
|
|
|
|
|