SELECT DISTINCT RTRIM(objs.NAME)
FROM sys.columns cols
INNER JOIN sys.objects objs on (cols.object_id = objs.object_id)
INNER JOIN sysindexes indx on (cols.object_id = indx.id)
WHERE (cols.name = 'ACTINDX') and (objs.type = 'U') and (indx.rowcnt <> 0)
The results are as shown below:
CM00100
CM20400
GL00100
GL00103
GL00104
GL00105
GL00201
GL10001
GL10002
GL10110
GL10111
GL20000
GL30000
GL40101
IV30500
IVC10300
IVC10500
MC00200
MC00201
MC00300
PA00002
PM10500
PM30700
PM80700
POP10390
POP30390
RM10601
RM30601
SOP10102
SOP10105
SVC00230
SVC00231
SVC00609
SVC00731
SVC05030
SY01100
SY03100
TX00201
UPR00100
UPR10209
UPR19901
UPR30401
UPR40500
UPR41200
By checking the rowcount in the sysindexes table, we are ensuring that we focus our efforts in those tables that contain data. Very helpful, isn't it?
SQL Server 2005 and SQL Server 2008
If working with Microsoft SQL Server 2005 or SQL Server 2008, the above query can be simplified as follows:
SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME = 'ACTINDX' ORDER BY TABLE_NAME
Until next post!
MG.-
Mariano Gomez, MIS, MCP, PMP
Maximum Global Business, LLC.
http://www.maximumglobalbusiness.com/
UPDATES TO THIS ARTICLE:
12/13/2008: Modified SQL query to look at system views and change article formatting.
01/08/2009: Added SQL Server 2005 and 2008 query to INFORMATION_SCHEMA
0 comments:
Post a Comment