Can I use EXISTS keyword in sql query for assignment of result

Posted by Shantanu Gupta on Stack Overflow See other posts from Stack Overflow or by Shantanu Gupta
Published on 2010-05-18T09:23:46Z Indexed on 2010/05/18 9:30 UTC
Read the original article Hit count: 263

Filed under:
|
|
|
|

Can I assign a value with EXISTS in the query. Currently it is giving me error Incorrect syntax near '='. But when I uses this query only it runs as expected.

IF EXISTS (SELECT @PK_LOGIN_ID=PK_LOGIN_ID FROM dbo.M_LOGIN 
    WHERE LOGIN_NAME=@LOGIN_NAME AND PASSWORD=@PASSWORD AND FK_ROLE_ID=@FK_ROLE_ID)
            RETURN @PK_LOGIN_ID
    ELSE
            RETURN 0

© Stack Overflow or respective owner

Related posts about sql

Related posts about tsql