Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
salmonraju
Yak Posting Veteran
54 Posts |
Posted - 2006-10-30 : 03:50:23
|
hi, how to use '=' operator in conditional statement for ex: in C language if( a==b&&b==c)how to use same statement in sql server is this wright if(a=b and b=c) if so , will a is assaigned by new value provided by b in if statement? |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-10-30 : 03:53:03
|
I have no idea what quote: if so , will a is assaigned by new value provided by b in if statement?
means.But otherwiseIF a = b AND b = c -- do something hereIF a = b OR b = c -- do something here Peter LarssonHelsingborg, Sweden |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-10-30 : 03:53:49
|
quote: how to use same statement in sql server is this wrightif(a=b and b=c)
Yesquote: if so , will a is assaigned by new value provided by b in if statement?
No. It is comparision operator KH |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-10-30 : 04:00:14
|
In SQL Server the = sign is both Assignment Operator as well as equal operator.from Books OnLinequote: Assignment OperatorTransact-SQL has one assignment operator, the equals sign (=). In this example, the @MyCounter variable is created. Then, the assignment operator sets @MyCounter to a value returned by an expression.DECLARE @MyCounter INTSET @MyCounter = 1
quote: = (Equals)Compares two expressions (a comparison operator). When you compare nonnull expressions, the result is TRUE if both operands are equal; otherwise, the result is FALSE. If either or both operands are NULL and SET ANSI_NULLS is set to ON, the result is NULL. If SET ANSI_NULLS is set to OFF, the result is FALSE if one of the operands is NULL, and TRUE if both operands are NULL.Syntaxexpression = expression
KH |
 |
|
salmonraju
Yak Posting Veteran
54 Posts |
Posted - 2006-10-30 : 04:39:05
|
Thank u for ur suggestions |
 |
|
samuelclay
Yak Posting Veteran
71 Posts |
Posted - 2006-10-30 : 15:39:05
|
The = is both an asignment operator and as a comparison operator, but it doesn't do both at the same time.so saying IF (@A=@B)-- Do somethingdoes not assign the value of B to A like some languages do. |
 |
|
|
|
|
|
|