Monday, March 12, 2012

Migartion issue with ORDER BY Clause

Please help me how to write the following query in SQL Server 2005

SELECT 3,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
CONVERT(char(10), fulldate, 126),
CONVERT(char(8), fulldate, 108),
flag = CASE Invalid WHEN 'Y' THEN 2 ELSE 1 END,
srk
FROM #raw
ORDER BY tag, parent, 'Value!3!date' asc

HUH?

What's the error?

And what's

Code Snippet

'Value!3!date' asc

|||

Sorry. i had not copied full query.Actually i am migrating Database from SQL Server 2000 to SQL Server 2005.I used SQL Server 2005 upgrade advisor.It shows where i need to modify the query.

Error is:Upgrade Advisor detected the use of noninteger constants in the ORDER BY clause of one or more statements. Noninteger constants are allowed (and ignored) in the ORDER BY clause when the database compatibility mode is set to 80 and earlier. Noninteger constants in the ORDER BY clause will cause the statement to fail when the database compatibility mode is set to 90.Upgrade Advisor detected the use of noninteger constants in the ORDER BY clause of one or more statements. Noninteger constants are allowed (and ignored) in the ORDER BY clause when the database compatibility mode is set to 80 and earlier. Noninteger constants in the ORDER BY clause will cause the statement to fail when the database compatibility mode is set to 90.

SELECT 1 AS tag,
NULL AS parent,
ISNULL(wmeWWTWMeter.wmeEARefNo,'not set')
AS [Station!1!stationReference],
sitSite.sitDescription AS [Station!1!stationName],
NULL AS [SetofValues!2!parameter],
NULL AS [SetofValues!2!qualifier],
NULL AS [SetofValues!2!dataType],
NULL AS [SetofValues!2!period],
NULL AS [SetofValues!2!characteristic],
NULL AS [SetofValues!2!units],
NULL AS [SetofValues!2!startDate],
NULL AS [SetofValues!2!startTime],
NULL AS [SetofValues!2!endDate],
NULL AS [SetofValues!2!endTime],
NULL AS [SetofValues!2!dayOrigin],
NULL AS [SetofValues!2!valuesPerDay],
NULL AS [Value!3!date],
NULL AS [Value!3!time],
NULL AS [Value!3!flag1],
NULL AS [Value!3!!element]
FROM sitsite INNER JOIN wmewwtwmeter ON sitsite.sitIdentifier = wmewwtwmeter.sitidentifier
WHERE sitSite.sitIdentifier = @.sitID
UNION ALL
SELECT 2,1,NULL,NULL,parameter,qualifer,dataType,period,characteristic,units,
CONVERT(char(10), mindate, 126),CONVERT(char(8), mindate, 108),
CONVERT(char(10), maxdate, 126),CONVERT(char(8), maxdate, 108),
dayOrigin,valuesPerDay,NULL,NULL,NULL,NULL
FROM #huwj INNER JOIN #minmax ON dummyKey = 'EA'
UNION ALL
SELECT 3,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
CONVERT(char(10), fulldate, 126),
CONVERT(char(8), fulldate, 108),
flag = CASE Invalid WHEN 'Y' THEN 2 ELSE 1 END,
Reading
FROM #raw
ORDER BY tag, parent, 'Value!3!date' asc

Could you please help in this.

Thank you,

Regards

Srikar

No comments:

Post a Comment