February 3, 2011 at 7:25 pm
Hi,
I get the error msg
"Procedure or function 'sp_MSforeachdb' expects parameter '@command1', which was not supplied."
when i run the following: What am i doing wrong?
EXEC sp_MSForeachdb 'USE [?]
IF DB_ID(''?'') > 4
BEGIN
select table_name from [?].information_schema.tables
where table_name = "table1"
END
'
thanks
February 3, 2011 at 7:43 pm
Try it this way
SP_MSForEachDb 'SELECT table_name from [?].information_schema.tables
where table_name = "table1"'
February 3, 2011 at 7:58 pm
it is working for me. I have tested it both on SQL 2005 SP3 and SQL 2008 R2. What version are you running it on?
February 3, 2011 at 8:07 pm
pankushmehta (2/3/2011)
it is working for me. I have tested it both on SQL 2005 SP3 and SQL 2008 R2. What version are you running it on?
SQL 2005 SP3 and SQL 2008
May 14, 2013 at 12:29 pm
Very well might be collation. Look in the master database for the sp_MSforeachdb reference under programming. If you have a server with non-standard collation and the sp call is not exactly as the master database has it, it will say it does not exist when it does. Hope that helps.
Rondall
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply