Saturday, September 6, 2008

Finding which column belongs to which table from database MsSql


 

Finding a column from the database

select * from syscolumns where name ='empid'

Finding an object from database

Select * from sysobjects where name='employee'

Finding the table name to which the column belongs

select * from sysobjects where id in(select id from syscolumns where name like'empid%'


 

Getting displayed the columns and tables to gather

Select a.name, b.name from sysobjects a, syscolumns b

Where a.id = b.id