BikeBoy20032004
MIS
Hi,
Can someone please tell me how to capture the data from sp_MSforEachDB into a variable?
I tried #temp, no luck.
I tried:
declare @dbname table (Col1 varchar (50))
EXEC sp_MSForEachDb 'IF EXISTS (SELECT 1 FROM ?.dbo.sysusers WHERE name = ''whoever'' AND isntname = ''1'')
''? '''
select * from @dbname
no joy.
Finally:
declare @myTable table (
col1 varchar (50) null
)
declare @command1 nvarchar(2000)
set @command1 = 'Insert into @dbname ''?'''
exec @myTable = sp_MSforeachdb @command1 = @command1
still no luck!
Can someone please tell me how to capture the data from sp_MSforEachDB into a variable?
I tried #temp, no luck.
I tried:
declare @dbname table (Col1 varchar (50))
EXEC sp_MSForEachDb 'IF EXISTS (SELECT 1 FROM ?.dbo.sysusers WHERE name = ''whoever'' AND isntname = ''1'')
''? '''
select * from @dbname
no joy.
Finally:
declare @myTable table (
col1 varchar (50) null
)
declare @command1 nvarchar(2000)
set @command1 = 'Insert into @dbname ''?'''
exec @myTable = sp_MSforeachdb @command1 = @command1
still no luck!