I am trying to count the records on the same table but on different databases then I want to put it in another table and read the results from there. The code I have at the moment is this
declare @cmd1 varchar(500)
set @cmd1 =
'if ''?'' like ''abcd%'' Select ''?'', count(*)
From tablename
exec sp_MSforeachdb @command1=@cmd1
the problem is that it is producing the same results for all the databases which I know is wrong. Can anyone help or is there a better way.
Angie
declare @cmd1 varchar(500)
set @cmd1 =
'if ''?'' like ''abcd%'' Select ''?'', count(*)
From tablename
exec sp_MSforeachdb @command1=@cmd1
the problem is that it is producing the same results for all the databases which I know is wrong. Can anyone help or is there a better way.
Angie