I am working on SQL Server stored procedure. I have a table \'User\' having fields (Id, Name, Email,Address).
I have following query returning All Users
<
SELECT 0 AS Id, 'All' AS Name
UNION ALL
SELECT Id, Name FROM Users;
You can even set a column numerically to keep the order even though UNION ALL
is applied
SELECT 0 RNO, 0 AS Id, 'All' AS Name
UNION ALL
SELECT ROW_NUMBER() OVER(ORDER BY Id)RNO, Id, Name
FROM Users
This will work even though a Zero
exists in your column Id
(may be a junk value)