Skip to content

Instantly share code, notes, and snippets.

@jonasgiehl
Created October 31, 2016 15:54
Show Gist options
  • Save jonasgiehl/bf89a128a1bddef0241b7b0163512fee to your computer and use it in GitHub Desktop.
Save jonasgiehl/bf89a128a1bddef0241b7b0163512fee to your computer and use it in GitHub Desktop.
Helps you find the columns of a table and the data types
SELECT
c.name 'Column Name',
t.Name 'Data type',
c.max_length 'Max Length',
c.precision ,
c.scale ,
c.is_nullable
FROM
sys.columns c
INNER JOIN
sys.types t ON c.user_type_id = t.user_type_id
WHERE
c.object_id = OBJECT_ID('TABLE_NAME')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment