tags:

views:

149

answers:

6
Select Null as Empty from (select * from  TblMetaData)
+5  A: 

It will yield a result set with one column named Empty which only contains NULL values. The number of rows will be equal to the number of rows available in TblMetaData.

Anders Abel
+10  A: 

Looks like, it is trying to get null rows for the same number of rows in tblMetaData.

EDIT: This could be written as
SELECT Null AS Empty FROM tblMetaData

shahkalpesh
+3  A: 

It looks like the result of one of two possible situations:

  1. The developer was getting paid per line, and threw in that query. It was probably originally structured to take more than one line.
  2. The developer was incompetent and this was the only way they could think of to generate a bunch of null values.
Abtin Forouzandeh
+3  A: 

The query returns a null value from each line of the table, so the only real information in the result is the number of records in the table.

This can of course be found out a lot more efficently using:

select count(*) as Count from TblMetaData

It's possible that the developer was not at all aware of the count aggregate (or how to search the web) and tried to get the number of records while making the result as small as possible.

Guffa
+1  A: 

it can be used to give the number of rows in the table TblMetaData with the column's name denoting the first letter of empty(in this case only). like suppose you gave

Select Null as Empty from (select * from TblMetaData)

so it will give E

n rows selected here n is the number of rows in the table.

suppose you gave

Select Null as XYZ from (select * from TblMetaData) then it would be same but the column's name would change like X

n rows selected

CadetNumber1
+1  A: 

It often used in this expression

select * from TableA where exists 
(select null from TableB where TableB.Col1=TableA.Col1)
neverend