mercredi 7 décembre 2016

SQL Server IF EXISTS THEN 1 ELSE 2

Using Sql Server 2012. I have a SP and part of it checks if a username is in a table. If it is, return a 1, if not, return a 2. This is my code:

IF EXISTS (SELECT * FROM tblGLUserAccess WHERE GLUserName ='xxxxxxxx') 1 else 2

However, I keep receiving the below error:

Incorrect syntax near '1'. 

Is this even possible with an IF EXIST?

Regards,

Michael

Aucun commentaire:

Enregistrer un commentaire