tags:

views:

71

answers:

3

if i m using query as

SELECT * FROM TABLE_NAME WHERE COLUMN1 = "ABC";

or

SELECT COLUMN1 FROM TABLE_NAME WHERE COLUMN1 = "ABC";

and COLUMN1 field of table does not contain data ABC what it will return?

A: 

If you are using SqlDatareader then the previous command will return nothing and reader.Read will return false becasue there is no rows.

But in general for null or empty columns in rows you will get DBNull and you can use IsDBNull method exposed in SqlDatareader class

Ahmed Said
+2  A: 

As best practice, you might want to use 'ABC' rather than "ABC", which sometimes has a different meaning...

That will simply return a grid without any rows... how that is interpreted depends on how you are doing your data access. It could manifest as a DataTable without any rows, or as an empty IQueryable<T> sequence, or as a DbDataReader that returns false from Read().

The first query returns all the columns, the second query just the cited column; but either way, if there is no matching data, there will be no rows.

Marc Gravell
A: 

Only rows with COLUMN1="ABC" will be returned at all, so in both cases, COLUMN1 will contain ABC. If no rows meet that criterion, no rows will be returned.

Draemon