Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
erikkl2003
Starting Member
14 Posts |
Posted - 2005-12-09 : 20:58:37
|
| in sql2000?Hello all,i can not seem to find the correct way to nest these if statements..i am tring to get a little better understanding of handeling messaging the client... on updates and inserts..thanks in advance for the help!erik.============================================Server: Msg 156, Level 15, State 1, Procedure Admin_Compare_Email_w_UserID, Line 28Incorrect syntax near the keyword 'ELSE'.Server: Msg 170, Level 15, State 1, Procedure Admin_Compare_Email_w_UserID, Line 32Line 32: Incorrect syntax near 'END'.================================================SET QUOTED_IDENTIFIER ON GOSET ANSI_NULLS ON GOALTER PROCEDURE Admin_Compare_Email_w_UserID@Admin_Email Varchar (200), /*Admin Check */ @UserID int,@UserType Varchar (30),@LastName Varchar (30),@Email Varchar (200)AsDECLARE @err Varchar (30)IF EXISTS (SELECT Email, FirstName, UserType FROM Users WHERE Email = @Admin_Email AND UserType = 'Admin')BEGIN IF EXISTS (SELECT FirstName FROM Users WHERE UserID = UserID AND Email = Email) BEGINSET @err = 'Users Credentials Match!' SELECT @err as lblerrorENDELSEBEGINSET @err = 'Users Credentials do not Match!' SELECT @err as lblerrorENDELSEBEGINSET @err = 'Admin Credentials do not Match!' SELECT @err as lblerrorENDGOSET QUOTED_IDENTIFIER OFF GOSET ANSI_NULLS ON GOIf you wait untill tomorrow; you will have no future. |
|
|
erikkl2003
Starting Member
14 Posts |
Posted - 2005-12-09 : 21:13:04
|
| bEEN Up way to long,,, for got to add the @ to my where clauseUserID = @UserID AND Email = @EmailIf you wait untill tomorrow; you will have no future. |
 |
|
|
azmi
Starting Member
37 Posts |
Posted - 2005-12-09 : 21:28:54
|
| you are repeating the else statement in your if statement. Try this;SET QUOTED_IDENTIFIER ONGOSET ANSI_NULLS ONGOALTER PROCEDURE Admin_Compare_Email_w_UserID@Admin_Email Varchar (200), /*Admin Check */@UserID int,@UserType Varchar (30),@LastName Varchar (30),@Email Varchar (200)AsDECLARE @err Varchar (30)IF EXISTS (SELECT Email, FirstName, UserType FROM Users WHERE Email = @Admin_Email AND UserType = 'Admin')BEGIN IF EXISTS (SELECT FirstName FROM Users WHERE UserID = UserID AND Email = Email) BEGIN SET @err = 'Users Credentials Match!' SELECT @err as lblerror END ELSE BEGIN SET @err = 'Users Credentials do not Match!' SELECT @err as lblerror ENDENDGOSET QUOTED_IDENTIFIER OFFGOSET ANSI_NULLS ONGOI had compiled sucessfully. Hope it's help u... |
 |
|
|
erikkl2003
Starting Member
14 Posts |
Posted - 2005-12-09 : 21:33:38
|
| Thank you very much for the reply!!erik...and the help..If you wait untill tomorrow; you will have no future. |
 |
|
|
|
|
|
|
|