Click here to Skip to main content
15,918,125 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This code gives me error when i try to execute
SQL
Create Proc spIsPasswordResetLinkValid
@GUID uniqueidentifier
as
Begin
   If(Exists(Select UserId from tblResetPasswordRequests where Id =@GUID)   
   Begin 
     Select 1 as IsValidPasswordresetLink
   End
   Else
   Begin
      Select 0 as IsValidPasswordResetLink
   End
End

The error it gives
Msg 156, Level 15, State 1, Procedure spIsPasswordResetLinkValid, Line 7
Incorrect syntax near the keyword 'Begin'.

Msg 156, Level 15, State 1, Procedure spIsPasswordResetLinkValid, Line 10
Incorrect syntax near the keyword 'Else'.

I dont know whats the error. Can someone point me to right direction.
Posted
Updated 3-May-15 2:02am
v2

Parenthesis do not match. Try this:
SQL
If Exists(Select UserId from tblResetPasswordRequests where Id =@GUID)


Edit
It occurs to me that your code is too procedural. It's better you avoid that with SQL. Moreover having logic in database is usually not recommended. You should simply query the data e.g.:
SQL
Select count(UserId) from tblResetPasswordRequests where Id =@GUID

and then evaluate the result in your application.
 
Share this answer
 
v2
Comments
ankur1163 3-May-15 8:07am    
I added @GUID))

One more parenthesis in the end and it worked. Thanks
Suvendu Shekhar Giri 3-May-15 8:07am    
Correct. +5
You are missing a bracket here
C#
If(Exists(Select UserId from tblResetPasswordRequests where Id =@GUID)


Try adding an end braket like
C#
If(Exists(Select UserId from tblResetPasswordRequests where Id =@GUID))

Hope, it helps :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900