kamagra how much to take

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:

  1. CREATE PROCEDURE [dbo].[GetColumnNames] @tableName VARCHAR(50)
  2. AS
  3. SELECT  name
  4. FROM    syscolumns
  5. WHERE   id = OBJECT_ID(@tableName)

Easy as pie! :)


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>