The Tech Pursuit
The Dev Shelf
Pages
Home
Interview Questions
About Me
February 1, 2012
Show Serial number in UNION Statement
We can show serial number in UNION statement using below approach.
SELECT
ROW_NUMBER
()
OVER
(
ORDER
BY
(
SELECT
1
))
AS
'SRNo'
,*
FROM
(
SELECT
'A'
AS
'Field1'
UNION
ALL
SELECT
'B'
AS
'Field2'
)
T
ORDER
BY
SRNo
That’s It.
Enjoy Learning.
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment