March 1, 2012 at 7:35 am
What is the difference between the below queries:
select * from table where col IS NOT NULL and
select * from table where col <> ''
Thanks in advance
March 1, 2012 at 7:42 am
The first finds rows where the column is not NULL
The second finds rows where the column does not equal an empty string.
CREATE TABLE Blah (
SomeString char(2)
)
Insert into Blah (null)
Insert into Blah ('')
Insert into blah ('abc')
IS NOT NULL will match 2 rows, != '' will match 1.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
March 1, 2012 at 11:03 am
Thank you very much.
How the below query works?
Select * from table
March 1, 2012 at 11:35 am
Errrr, it retrieves all rows from the table.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply