dbTalk Databases Forums  

Basic Syntax explanation

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Basic Syntax explanation in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
jw56578@gmail.com
 
Posts: n/a

Default Basic Syntax explanation - 05-12-2005 , 01:48 PM






In T sql for sql server, what is the technical difference between the
comparisons "is" and "="
for example:
set @test = null

print @test is null -> true
print @test = null -> false


Reply With Quote
  #2  
Old   
David Portas
 
Posts: n/a

Default Re: Basic Syntax explanation - 05-12-2005 , 03:04 PM






In SQL, NULL represents a missing/unknown value. The basic comparison
operators like =, <>, <, >, IN, etc return an UNKNOWN result when NULLs are
compared. IS NULL / IS NOT NULL are special types of comparison for
verifying the presence or absence of NULLs.

Read about NULLs and three-value logic in Books Online:
http://msdn.microsoft.com/libr*ary/e...d_02_8p*wy.asp

--
David Portas
SQL Server MVP
--



Reply With Quote
  #3  
Old   
David Portas
 
Posts: n/a

Default Re: Basic Syntax explanation - 05-12-2005 , 03:11 PM



Sorry. Broken link. Try:
http://msdn.microsoft.com/library/de...qd_02_8pwy.asp

--
David Portas
SQL Server MVP
--



Reply With Quote
  #4  
Old   
--CELKO--
 
Posts: n/a

Default Re: Basic Syntax explanation - 05-13-2005 , 09:33 AM



Read about three valued logic in any intro SQL book. You got
everything wrong:

(@test = NULL) -> UNKNOWN for all values of @test

This makes a big difference in DDL and DML clauses.

There is no "IS" in SQL -- that reserved word is part of several
multi-word operators such as IS NULL, IS NOT NULL, and some that are
not widely implemented yet.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.