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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-07-15 : 08:23:42
|
Andy M writes "Hi,Hello again, I seem to be really messing up the SQL server XML facilities, they just don't seem to support the functionality I need. Ah well... this time I'm trying to make a order by parameter specify the order. This is covered nicely by your man in this article http://www.sqlteam.com/item.asp?ItemID=2209 However when I try it in the following code, it will not work when I'm using an XML explicit. The trouble is using column named something liketable.field1 AS [awkward!1!naming], This makes the following code produce some funny syntax errorsORDER BY CASE WHEN @Order_By = 1 THEN [article!2!name] WHEN @Order_By = 2 THEN [article!2!status] ELSE [article!2!name]END DESC I've tried quite a few ways of working round it, but can't seem to get the desired result.Over to you guys...CheersAndy M" |
|
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2002-07-16 : 07:36:18
|
| does the code work without the FOR XML statement?ORDER BY + CASE statements when mixed have restrictions on their use, in particular to do with the datatypes of the fields being ordered.Are name and status the same datatypes? AFAIK they need to be. |
 |
|
|
andymaule
Starting Member
6 Posts |
Posted - 2002-07-16 : 08:18:52
|
| They aren't the same data type... I'll try thworking round the data types and see if I can come up with something, thanks for the help!Andy |
 |
|
|
|
|
|