SQL Server Performance

Simulating undocumented Procedures

Discussion in 'Other SQL Server Blogs around the Web' started by Anonymous, May 19, 2008.

  1. Anonymous New Member

    Sometimes you may want to run a query against each database Suppose you want to find all dabase names where particular table exists. You can use undocumented procedure EXEC sp_msforeachdb 'SELECT table_catalog FROM ?.INFORMATION_SCHEMA.TABLES where table_name=''your_table''' Because they are undocmented, you cant always rely on them. Alternatively you can use the following methods 1 WHILE LOOP declare @dbname varchar ( 100 ), @database_id int , @table_name varchar ( 100 ) select @dbname = '' , @database_id...(<a href="http://sqlserver-qa.net/blogs/t-sql/archive/2008/05/19/4273.aspx">read more</a>)<img src="http://sqlserver-qa.net/aggbug.aspx?PostID=4273" width="1" height="1">

Share This Page