jump to navigation

Re-order the column order in a query result in SQL Server 2005 June 9, 2008

Posted by fofo in Sql Server 2005, SQL Server 2008.
trackback

When we execute a query in SQL Server 2005 we can see the results in a table-grid format.Sometimes we need to reorder the columns in the query results window. We can obviously do that by re-writing the query but in SQL Server 2005 and SQL Server 2008 we can reorder the columns in the grid-table window by just drag and drop.

  • Launch SQL Server 2005 or 2008
  • Connect to a database (e.g Northwind)
  • Write a simple query in the query window (SELECT * from Categories)
  • In the query results window just drag the column and drop it in the place you want

 See the picture below

 

 

Comments»

1. Mikael Söderström - June 17, 2008

I prefer to write the fields in the right order from the beginning.

Example:
SELECT field1, field2, field3 FROM table

It returns the fields in that order. If I want it the other way I can write:

SELECT field3, field2, field1 FROM table

The reason why I prefer that is because that´s how my application will get the data itself. :-)

/Mikael Söderström

2. fofo - June 17, 2008

yes mikael i agree with you. i do the same. i wrote that in my post as well. that is just a tip. thanks


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: