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 - 2001-11-13 : 19:25:11
|
| Magnus writes "Hi!!I am trying to run the this query but it doesn't run for some values but it does for some...DECLARE @ORDERBY TINYINTSELECT @ORDERBY = 3SELECT *, NumberOfRecords = (SELECT COUNT(1) FROM Temp) FROM Temp ORDER BY CASE WHEN @ORDERBY = 1 THEN TitlesName WHEN @ORDERBY = 2 THEN Language WHEN @ORDERBY = 3 THEN Username WHEN @ORDERBY = 4 THEN DownloadDate WHEN @ORDERBY = 5 THEN Grade ELSE Grade ENDIf I have @ORDERBY less than 4 the following error is displayed:Server: Msg 241, Level 16, State 1, Line 4Syntax error converting datetime from character string.If it's bigger or equal to 4 the query runs perfectly ?!?!?!Titlesname, Language, username is VARCHAR()DownloadDate is DateTimeGrade is TINYINTI can't figure out what is wrong, I use SQL Server 2000 with SP1 and Win2000 SP2Thanks- Magnus" |
|
|
|
|
|