EXEC sp_msforeachdb
Below is the example.
sp_msforeachdb @command1='USE ?;IF DB_ID(''?'') > 4 begin EXEC sp_changedbowner ''sa'' end'
sp_msforeachdb @command1='USE ?;SELECT * FROM sys.Tables'
Below is the example.
sp_msforeachdb @command1='USE ?;IF DB_ID(''?'') > 4 begin EXEC sp_changedbowner ''sa'' end'
sp_msforeachdb @command1='USE ?;SELECT * FROM sys.Tables'
Comments