When you have a table with many columns, it can become a chore to remember all of the column names and find what you need. This script displays the selected rows vertically with the columns in alpha order to help locate columns when you don't know the exact names (or if you just want to see all the columns without scrolling horizontally). This uses SQL Server 2005's UNPIVOT command, and so will not work in SQL 2000.
It will not display columns having null values or columns of type text, ntext, image, or timestamp.
It takes two parameters, the second of which is optional: tablename (in single-quotes) and an optional Where clause in quotes (including the word WHERE).
vselect 'mytable', 'where id=123'