San Diego Website design home Contact Us Client Login


Saturday, May 17, 2008

An expression of non-boolean type specified in a context where a condition is expected, near ')'

This is an syntax error in SQL when the 'if' statement is not correctly formatted.

In SQL an 'if' statement in a stored procedure can look like this:

 

IF  'condition'

BEGIN

'statement'

END

 

When the conditional statement is not formattted correctly you'll get the error for example I had:

IF  @variable = 'ALL' OR ' '

BEGIN

set @variable = NULL

END

 

I am checking the value of the incoming parameter and changing it to NULL. I do this to avoid dynamic SQL in my where clause.  But this is another topic.

SO

Change the if statement to this and avoid my mistake:

IF  @variable = 'ALL' OR @variable = ' '

BEGIN

set @variable = NULL

END

 

Please support this blog by clicking on my sponsors to the right.

 

Good Luck!

Comments

Name
URL
Email
Email address is not published
Remember Me
Comments

CAPTCHA
Write the characters in the image above

San Diego Website Design
San Diego Flash Design
Testimonials
Contact Us
Support
Privacy Policy
Site Map