Skip to main content

To get List of Column names by giving table Names

Hi, here I will Query you how to get the list of column names by passing the table name as input. There are two methods to get the output. First Query gives better performance than Second Query.


Method 1 :

SELECT
           sc.Name [Field Name]
     FROM
           SYSCOLUMNS sc
           inner join SYSOBJECTS so ON
           so.id = sc.id
     WHERE
           so.name = @tablename


Method 2 :

SELECT name FROM SYS.COLUMNS
     WHERE OBJECT_NAME(OBJECT_ID) = @tablename
     ORDER BY column_id  



Comments


  1. It's very useful article with inforamtive and insightful content and i had good experience with this information. We, at the CRS info solutions ,help candidates in acquiring certificates, master interview questions, and prepare brilliant resumes.Go through some helpful and rich content Salesforce Admin syllabus from learn in real time team. This Salesforce Development syllabus is 100% practical and highly worth reading. Recently i have gone through Salesforce Development syllabus and Salesforce Admin syllabus which includes Salesforce training in USA so practically designed.

    ReplyDelete

Post a Comment