.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Sql Server >> Post New QuestionBookmark and Share Subscribe to Forum

Order By in Sql [its an Urgent]

Posted By: Sunil     Posted Date: December 04, 2008    Points:2   Category :Sql Server
Hi,

i want to sort some column in table!

How i am doing:-

Select * from tablename Order By columnName

This gives me right data
But Problem is Here?????

It not change in actual table data, that query only shows temporary view..?

So can any one please help me How this query change my actual table column field as showing in temporary view.

Responses
Author: Amit Mehra             
Posted Date: December 04, 2008     Points: 5   

Hi,
I dont know why you need this when you can sort into client side or using order by clause. but try like this

1) Insert all the data into temp table
2) delete the existing data
3) insert again the the data stored in temp table into the original Table using order by command in temp table.

Hope this helps

Thanks,
Amit
Please "Mark As Answer " if this post help you.
Author: Shashi Ray             
Posted Date: December 07, 2008     Points: 5   

Hello sir, Please try with code,

First Run this Query,
1. Select * into tablenameNew from tablename where 1>2;
This query is created new table, where tablenameNew=NewTableName ane tablename=OldTableName.

than,

2. insert into tablenameNew select distinct * from tablename order by ColumnName;
This Query is Copy the Data from tablename and Paste in tablenameNew.


Shashi Ray

Shashi Kant Ray


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend