December 19, 2006 at 6:46 am
In sp_MyWork using this call method:
SET @sql = 'EXEC ?.dbo.sp_MyWork ' + CONVERT(varchar(10), @a)
EXEC sp_MsForEachDB @sql
I cannot query data dictionnary (sys schema views). I believe it is the data dictionnary from the master database that is always queried.
One exemple: IF exists (select 'x' from sys.schemas where name = @username) ...
I don't receive the correct "answer".
What am I missing?
Regards.
Carl
December 19, 2006 at 8:34 am
I finally found that every query must be dynamic and fully qualified:
EXEC ('SELECT ''X'' FROM '+db_name()+'.sys.schemas WHERE name = '+''''@username+'''')
IF (@@ROWCOUNT = 1)
...
sp_MSforeachdb is really a "black box"...
Carl
December 19, 2006 at 8:43 am
It's not unsupported for no reason (unless it changed in 2005).
December 19, 2006 at 8:52 am
Its as you said...
By the way I didn't have the time to schedule a public humiliation session, too much work to do fighting against sp_MSforeachdb...
Thanks for your help.
Carl
Viewing 4 posts - 16 through 18 (of 18 total)
You must be logged in to reply to this topic. Login to reply