What is the easiest way to find a sql query returns a result or not?
Posted
by bala3569
on Stack Overflow
See other posts from Stack Overflow
or by bala3569
Published on 2010-04-09T05:38:07Z
Indexed on
2010/04/09
5:43 UTC
Read the original article
Hit count: 354
Consider the following sql server query ,
DECLARE @Table TABLE(
Wages FLOAT
)
INSERT INTO @Table SELECT 20000
INSERT INTO @Table SELECT 15000
INSERT INTO @Table SELECT 10000
INSERT INTO @Table SELECT 45000
INSERT INTO @Table SELECT 50000
SELECT *
FROM (
SELECT *,
ROW_NUMBER() OVER(ORDER BY Wages DESC) RowID
FROM @Table
) sub
WHERE RowID = 3
The result of the query would be 20000
..... Thats fine as of now i have to find the result of this query,
SELECT *
FROM (
SELECT *,
ROW_NUMBER() OVER(ORDER BY Wages DESC) RowID
FROM @Table
) sub
WHERE RowID = 6
It will not give any result because there are only 5
rows in the table.....
so now my question is
What is the easiest way to find a sql query returns a result or not?
© Stack Overflow or respective owner