Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
gagani
Posting Yak Master
112 Posts |
Posted - 2012-05-31 : 10:37:56
|
select orderid, customer_name from customer where orderid in(530076,560111,524091,804141) order by customer_nameThe output is 530076 HORN560111 JOHN524091 KEITH804141 ADAM RUSSELLIs there anyway I can get the output as 530076 ADAM RUSSELL560111 HORN524091 JOHN804141 KEITH |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-05-31 : 10:42:23
|
Shoould be that. Are you sure you have the order by statement? Where do you output the data to?If you are inserrting into a table the optimiser can ignore the order by clause as table data is not ordered.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
gagani
Posting Yak Master
112 Posts |
Posted - 2012-05-31 : 10:51:28
|
yes, i am using the order byThe output is 530076 HORN560111 JOHN524091 KEITH804141 ADAM RUSSELLbut i want the output as804141 ADAM RUSSELL530076 HORN560111 JOHN524091 KEITH |
|
|
gagani
Posting Yak Master
112 Posts |
Posted - 2012-05-31 : 10:55:15
|
It is doing alphabetical ordering from the table which has got only one word as customer_name and then it is doing alphabetical ordering for the customer_name with two words |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-05-31 : 11:18:48
|
As far as the server is concerned it only has one name - some have a space in them.A should come before H - can you post the data.Give a table variable, populate it and give the query==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-05-31 : 11:21:15
|
Something likedeclare @t table (i int, s varchar(20))insert @t select 1,'hhh'insert @t select 2,'jjj'insert @t select 3,'kkk'insert @t select 4,'aa zzzzzz'insert @t select 5,'hhh'insert @t select 6,'hhh'select *from @twhere i in (1,2,3,4)order by s==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
|
|
|
|
|