Posts

Showing posts from October, 2015

SQL Table Row Data show in column data

Image
SELECT * FROM (SELECT CAST(mlblmsg AS varchar(max)) AS mlblmsg,clblcode FROM warninglabels) t PIVOT (MAX(mlblmsg) FOR clblcode IN ([0001],[0002],[003],[0004],[0005],[0006]))p


How to find if a Column is used anywhere in the database

To get the table where this column use you can use this query.

SELECT * FROM sys.tables WHERE tables.object_id IN (SELECT OBJECT_ID FROM sys.columns WHERE columns.name LIKE '%CDRUGNAME%') -- use your column name