Returning Table Field Names
So, today one of my friends asked me if I knew how to return the names of all the fields in a table using a stored procedure so that he could build the names into a generic string collection. This is how you do it:
SQL:
-
CREATE PROCEDURE [dbo].[GetColumnNames] @tableName VARCHAR(50)
-
AS
-
SELECT name
-
FROM syscolumns
-
WHERE id = OBJECT_ID(@tableName)
Easy as pie!
No Comments »
No comments yet.
RSS feed for comments on this post. TrackBack URL























Articles & Research
SharePoint Architecture
Personal/Off-Topic
Article Or Research Filed Under 
