Skip to content

Instantly share code, notes, and snippets.

@seantunwin
Created February 7, 2019 15:00
Show Gist options
  • Select an option

  • Save seantunwin/72a5bd57d21bc1e72eb623b2370802e4 to your computer and use it in GitHub Desktop.

Select an option

Save seantunwin/72a5bd57d21bc1e72eb623b2370802e4 to your computer and use it in GitHub Desktop.
MSSQL: Get Table Coumns Names and Column Count
-- Get Column Name from a table
SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = @table;
-- Get total number of Columns
SELECT COUNT(*) FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = @table;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment