I am trying to find table columns in different tables and different databases.
So far, I do have a query to do that, however it does not tell me in which database that column and table lays in.
Current code:
SELECT sys.columns.name AS ColumnName, tables.name AS TableName FROM sys.columns JOIN sys.tables ON sys.columns.object_id = tables.object_id WHERE sys.columns.name LIKE '%COLUMNNAME%' Does anyone have an idea what I need to add to display the database name as well?
DB_NAME().sysobjects when you first connect. Perhaps is on a different schema and you're looking in the wrong place; but not having refreshed the Object Exp[lorer is the very likely candidate in my opinion. I can only guess though; i can't see what you do.