September 19, 2005 at 5:14 am
Can you please suggest various ways to select all column names in a table.
September 19, 2005 at 5:28 am
To do what exactly?
If you just want a list of fields then SET FMTONLY ON before the query will give you what you need.
September 19, 2005 at 5:32 am
select top 0 * from <table name>
My Blog:
September 19, 2005 at 6:25 am
Select * from dbo.TableName where 1 = 0
September 19, 2005 at 6:33 am
Not recommended but another approach
SELECT SO.[name], SC.colorder, SC.[name]
FROM (SELECT [id], [name] FROM sysobjects WHERE xtype = 'U') SO
INNER JOIN syscolumns SC ON SO.[id] = SC.[id]
WHERE SO.[name] = 'YourTableNameHere'
ORDER BY SO.[name], SC.colorder
Good Hunting!
AJ Ahrens
webmaster@kritter.net
September 19, 2005 at 9:58 pm
Thanks Guys!!!!!!!!!!!
December 5, 2005 at 10:21 pm
You could use this query:
select name, colorder from syscolumns where object_name(id) = 'yourtablename'
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply