I'm gonna start a new category today called 'snippets'. I'm going to use this category to post helpful little snippets of code, markup, SQL or whatever that I use often while developing new software. This will be mostly for my own purposes, but it will be up here on my blog for all to see. In time it'll be a nice little reference.
In SQL Server 2005, the object explorer lists a tables columns in the same order they are entered in the tables schema. For large tables, this can make it difficult to quickly find exaclty what a column is named, and to get its type, etc. To get a alphabetical list, you can query against the information_schema.columns system view:
SELECT column_name, data_type, character_maximum_length
FROM information_schema.columns
WHERE table_name = 'myTable' ORDER BY column_name
snippets