Hi,
Can someone tell me what i wrong with this sproc? I get this error:
SPROC:Code:Server: Msg 156, Level 15, State 1, Procedure sp_CAPL_InsertUpdateCompany_Normal, Line 22 Incorrect syntax near the keyword 'ELSE'. Server: Msg 156, Level 15, State 1, Procedure sp_CAPL_InsertUpdateCompany_Normal, Line 26 Incorrect syntax near the keyword 'ELSE'.
Code:ALTER PROCEDURE sp_CAPL_InsertUpdateCompany_Normal @coID INT, @coTypeID INT, @phone_code NVARCHAR(10), @phone_number NVARCHAR(20), @phone_ext NVARCHAR(10), @fax_code NVARCHAR(10), @fax_number NVARCHAR(20) AS DECLARE @conID INT IF EXISTS (SELECT [ID] FROM tblCAPLCompanies_Normal WHERE [ID] = @coID) UPDATE tblCAPLCompanies_Normal SET coTypeID = @coTypeID WHERE [ID] = @coID SET @conID =( SELECT contactID FROM tblCAPLCompanies_Normal WHERE [ID] = @coID) IF @conID = 0 INSERT INTO tblContacts(phone_code, phone_number, phone_ext, fax_code, fax_number) VALUES (@phone_code, @phone_number, @phone_ext, @fax_code, @fax_number) SET @conID = SCOPE_IDENTITY() INSERT INTO tblCAPLCompanies_Normal(contactID) VALUES (@conID) ELSE UPDATE tblContacts SET phone_code = @phone_code, phone_number = @phone_number, phone_ext = @phone_ext, fax_code = @fax_code, fax_number = @fax_number WHERE ID = @conID ELSE INSERT INTO tblContacts(phone_code, phone_number, phone_ext, fax_code, fax_number) VALUES (@phone_code, @phone_number, @phone_ext, @fax_code, @fax_number) SET @conID = SCOPE_IDENTITY() INSERT INTO tblCAPLCompanies_Normal(contactID) VALUES (@conID)


Reply With Quote