I would like to have all the tables having one column called XXX
I've tried the following query but it's not working.
SELECT object_id
FROM sys.columns 
WHERE name = 'XXX';
I would like to have all the tables having one column called XXX
I've tried the following query but it's not working.
SELECT object_id
FROM sys.columns 
WHERE name = 'XXX';
 
    
    SELECT table_schema
     , table_name
     , column_name
FROM   information_schema.columns
WHERE  column_name LIKE '%test%'
You've mentioned in your question comments that "it's not working" =
pressing F5 is aking me to create a report file
In Management Studio you have a few options for what to do with your query results:

CTRL + TCTRL + DCTRL + SHIFT + FSounds like you've hit the "Results to File" button (or key combination).
 
    
    Here's one that will grab both the column and the table it belongs to:
SELECT DISTINCT so.name AS tablename, sc.name AS columnname 
FROM syscolumns sc
INNER JOIN sysobjects so
ON so.id=sc.id
WHERE sc.name LIKE '%XXX%'
ORDER BY so.name, sc.name
