Monday, 26 May 2014

Query to find out list of tables which has a particular column....

Below query is used to find out the list tables which has particular column.



SELECT OBJECT_NAME(OBJECT_ID) FROM SYS.COLUMNS  SC
WHERE NAME LIKE '%CUSTID%'

Finding out list of Stored Procedures which uses particular Table/Column....

So many times, while doing the impact analysis we need to find out the list of Stored procedures which uses a particular Table/Column.

Below query gives us the list stored procedures.


SELECT OBJECT_NAME(SC.ID),TEXT FROM SYSCOMMENTS SC
JOIN SYSOBJECTS SO ON SC.ID=SO.ID WHERE SC.TEXT LIKE '%CUSTID%'
AND SO.TYPE='P'