Retrieving Column Names of a table from database using SQL
Introduction
Recently I was in a requirement to find all column names w.r.t. a database table. I found the solution and thought this may be useful for others too. So compiling it here under this SQL Server section.
Retrieving Column Names of a table using SQL:-
CREATE
PROCEDURE [GetTableColumns]
(
@TableName
VARCHAR(30)
)
AS
BEGIN
SELECT Column_Name FROM INFORMATION_SCHEMA.COLUMNS WHERE
Table_Name
=@TableName
END
Conclusion
We have created our own stored procedure for retrieving table columns.