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 :
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