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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 UNION With Dynamic Order By Failing

Author  Topic 

excelthoughts
Starting Member

5 Posts

Posted - 2007-11-30 : 00:03:20
Hi,
Can anyone help as to how to get this to work? dbo.parseInt is a Function which sorts Alpha Numerically. If I removed the top part of the UNION, the Procedure works fine.

ALTER PROCEDURE dbo.ByJobNoAlphaNumeric as
SELECT 0 AS JobID, '<All Jobs>' AS JobNo
UNION SELECT JobID, JobNo FROM tbl
ORDER BY dbo.parseInt(JobNo)

Regards
Andrew

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-11-30 : 00:06:22
[code]SELECT JobID, JobNo
FROM
(
SELECT 0 AS JobID, '<ALL Jobs>' AS JobNo
UNION
SELECT JobID, JobNo FROM tbl
) j
ORDER BY dbo.parseInt(JobNo)
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

excelthoughts
Starting Member

5 Posts

Posted - 2007-11-30 : 00:17:27
Thanks for your quick reply
Go to Top of Page
   

- Advertisement -