Many times there’s a requirement to get all columns for a particular table in database. Hence here is a SQL Query that does that.
SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'Your Table Name'
ORDER BY ORDINAL_POSITION
For example if I want to get all columns in Employees table of NorthWind database then it would be
SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'Employees'
ORDER BY ORDINAL_POSITION
There’s also a System Stored Procedure sp_columns that also does the above but with some additional information
EXEC sp_columns 'Your Table Name'
If I want to get all columns in Employees table of NorthWind database then it would be
EXEC sp_columns 'Employees'
Try it your self