Microsoft SQL Server 2008 Tips/Tricks
For all examples shown here, the database if not explicitly shown is named
Services. Snippets were tested on Microsoft SQL Server 2008.
Show all columns of a database table
Examples (mostly equivalent results):
SELECT name FROM sys.columns WHERE object_id = OBJECT_ID('dbo.Users')
SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='Services.dbo.Users'
exec sp_help 'Users'
In my case I had drilled down using the
Microsoft SQL Server Management Studio prior to running the queries, so the tables could have simply been specified as
Users with the same result.