I'm able to query all the databases via How to run the same query on all the databases on an instance? but not sure how to run the query by matching a specific column and value.
example, assume column name is code. query + code='THBN'
Thanks.
I'm able to query all the databases via How to run the same query on all the databases on an instance? but not sure how to run the query by matching a specific column and value.
example, assume column name is code. query + code='THBN'
Thanks.
EXECUTE sp_MSForEachDB
'USE ?;
SELECT * from table where code=''tbhn''';
you could also ignore system databases like below
EXECUTE sp_MSForEachDB
'if db_id()>4
begin
SELECT * from table where code=''tbhn''
end';