How to find out to which table the column name belongs to ?
How to find out to which table the column name belongs to ?
Ans:
SELECT TABLE_NAME=SYSOBJECTS.NAME,
COLUMN_NAME=SYSCOLUMNS.NAME,
DATATYPE=SYSTYPES.NAME,
LENGTH=SYSCOLUMNS.LENGTH
FROM SYSOBJECTS
JOIN SYSCOLUMNS ON SYSOBJECTS.ID = SYSCOLUMNS.ID
JOIN SYSTYPES ON SYSCOLUMNS.XTYPE=SYSTYPES.XTYPE
WHERE SYSOBJECTS.XTYPE=’U’
AND SYSCOLUMNS.NAME LIKE (‘COLUMNAME2FIND%’)
ORDER BY SYSOBJECTS.NAME,SYSCOLUMNS.COLID
--keep posting
Comments
Post a Comment