Order by clause with Union in Sql Server

Since you are anyway hardcoding 0, All just add a space before the All

Select 0 PartyId, ' All' Name
Union
select PartyId, Name
from PartyMst
ORDER BY Name

SQL FIDDLE

Raj


You need to use a sub-query with CASE in ORDER BY clause like this:

SELECT * FROM
(
  Select 0 PartyId, 'All' Name
  Union
  select PartyId, Name
  from PartyMst
) tbl
ORDER BY CASE WHEN PartyId = 0 THEN 0 ELSE 1 END
,Name

Output:

PARTYID NAME
0 All
2 AAKASH & CO.
3 SHAH & CO.
1 SHIV ELECTRONICS

See this SQLFiddle