Thursday, July 5, 2007

Using Exists statement in If statements

You'd think there'd be a more elegant way to do this, but...

 

IF NOT EXISTS(

SELECT TOP 1 1 FROM mytable WHERE myid = @myid

)

BEGIN

...do stuff

END

 

No comments: