RHPT
RHPT

Reputation: 2650

Conditional IF in T-SQL Errors?

I have this stored procdure

CREATE PROC dob.p_foobar
(
  @foo bit = NULL,
  @Bar bit = NULL
)

AS

IF @Foo == 1
BEGIN
   SELECT 'Hello, World'
END

When I parse, I get the error "Incorrect syntax near '='".

Please tell me what I'm doing wrong. I know it's something stupid, but I just can't figure it out.

Thank you

Upvotes: 0

Views: 154

Answers (2)

Jason Kleban
Jason Kleban

Reputation: 20808

No ==

IF @Foo = 1
BEGIN
    ...
END

Upvotes: 1

Joe Phillips
Joe Phillips

Reputation: 51160

SQL uses a single equals sign (=), not a double equals sign (==)

Upvotes: 4

Related Questions