Skip to content

Instantly share code, notes, and snippets.

@Faz95210
Created June 13, 2018 09:47
Show Gist options
  • Save Faz95210/5d502c874852f3d50e5cf7f5d9314b0c to your computer and use it in GitHub Desktop.
Save Faz95210/5d502c874852f3d50e5cf7f5d9314b0c to your computer and use it in GitHub Desktop.
[Get columns list SQLserver] Get table's column in sql server #SQLServer
SELECT c.name 'Column Name'
FROM sys.columns c
INNER JOIN sys.types t ON c.user_type_id = t.user_type_id
LEFT OUTER JOIN
sys.index_columns ic ON ic.object_id = c.object_id AND ic.column_id = c.column_id
LEFT OUTER JOIN
sys.indexes i ON ic.object_id = i.object_id AND ic.index_id = i.index_id
WHERE
c.object_id = OBJECT_ID('YOUR_TABLE_NAME')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment