tags:

views:

21

answers:

1

Hi,

I I've followed the other stackoverflow question but I get the exception of token error that stops at WHERE in this line:

INSERT INTO Users(nick, place, sex) 
VALUES(@nick, @place, @sex) 
WHERE NOT EXISTS (SELECT nick FROM Users WHERE nick=@nick)

nick in Users is unique and I can't insert it there.

+2  A: 

You can't have a where clause if you're using VALUES.

You can instead do:

INSERT INTO Users (nick,place,sex)
SELECT @nick,@place,@sex
WHERE NOT EXISTS (SELECT * FROM Users WHERE nick=@nick)
Damien_The_Unbeliever