All Columns in a Table


/ Published in: SQL
Save to your folder(s)

Simple but...


Copy this code and paste it in your HTML
  1. DECLARE @TableName sysname;
  2. SELECT @TableName = 'Users'
  3.  
  4. SELECT c.column_id ,
  5. c.name ,
  6. sys.types.name ,
  7. c.is_nullable
  8. FROM sys.columns c INNER JOIN sys.types ON c.system_type_id = sys.types.system_type_id
  9. WHERE OBJECT_NAME(c.object_id) = @TableName
  10. ORDER BY c.column_id

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.