views:

22

answers:

1

hi,

i want to get column names of table in sys.table using its object_id

regards vivek

+1  A: 
SELECT name
FROM sys.columns
WHERE [object_id] = OBJECT_ID(N'[dbo].[<your table name here>]')

If you know the object id, you can stick it in instead of OBJECT_ID(N'[dbo].[<your table name here>]'). Or, you could also stick a variable there.

fire.eagle
i think OP already has the object_id of the table. so should OBJECT_ID(N'[dbo].[<your table name here>]') be replaced by <your object id here>?
potatopeelings
Yea, it probably should. I just went ahead and included the syntax for getting the ID also anyways. I do have a note there saying you can just swap it in though.
fire.eagle