Twitter <%=Resources.labels.subscribe %>

SQL Server 2005 : List columns alphabetically

  • 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

    Tags:

    Permalink |

Add comment




  Country flag
biuquote
  • Comment
  • Preview
Loading


Intro

My name is Brent Lamborn. I´m 35 years old and I live in Nebraska. I've been coding with the .NET Framework since 2003. I'm a former Marine and I have 5 boys.


View Brent Lamborn's LinkedIn profileView Brent Lamborn's profile

Sponsored By

Categories

Tag Cloud

Blog Roll