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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How do i validate 3 expressions ?

Author  Topic 

mary_itohan
Posting Yak Master

191 Posts

Posted - 2008-09-07 : 06:40:23
Hello,
am trying to run an if statement.

How do i validate 3 expressions. Here is my code

All variables below are integers.

the expression left(@each_recipient,@len_countrycode)

the value of @len_countrycode is an integer that is evaluated at runtime.



if ((@length = @defaultlength) and (isnumeric(@each_recipient)) and (left(@each_recipient,@len_countrycode) = @defaultcountry ))


thanks



I get this error when i run it

Msg 4145, Level 15, State 1, Procedure Cellulant_SendSMS_billing, Line 71
An expression of non-boolean type specified in a context where a condition is expected, near 'and'.











Yes O !

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-09-07 : 06:52:36
try

if ((@length = @defaultlength) and (isnumeric(@each_recipient)=1) and (left(@each_recipient,@len_countrycode) = @defaultcountry ))
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-07 : 07:28:30
Also keep in mind that isnumeric is not fully reliable. refer the below for more details:-


http://sqlblogcasts.com/blogs/madhivanan/archive/2007/08/27/enhanced-isnumeric-function.aspx
Go to Top of Page
   

- Advertisement -