How to get list of fields under a table
It is very simple to get list of fields or column under a sql server table. With the help of sys object we can get the column list. Here is an example:
select * from syscolumns where id =
(select id from sysobjects where type='U' and name like 'SSC_School1')
OR
select * from syscolumns where id =
(select object_id from sys.objects where type='U' and name like 'SSC_School1')
OR
select * from sys.columns where object_id =
(select object_id from sys.objects where type='U' and name like 'SSC_School1')
Here 1) type refer to object (sql server object like table, sp etc) and 'U' refer to user defined table
2) name refer to your Table name.
Post Reference: Vikram Aristocratic Elfin Share
No comments:
Post a Comment