Hey guys i need your help, i am getting errors when creating this query. What this query does is preety simple. It take 3 parameter firstname, lastname and guid(unique number combination), then it check if that person already exists. If the person does, then output the person's id and if not, insert the person then out the new id. However, it get this error:
Msg 102, Level 15, State 1, Procedure Check_IF_Person_Exist, Line 4
Incorrect syntax near '@intPersonID'.
Msg 137, Level 15, State 1, Procedure Check_IF_Person_Exist, Line 12
Must declare the scalar variable "@intPersonID".
Msg 137, Level 15, State 1, Procedure Check_IF_Person_Exist, Line 19
Must declare the scalar variable "@intPersonID".
Create Procedure Check_IF_Person_Exist(@FirstName nvarchar(50),@LastName nvarchar (50),@Guid int(11))
@intPersonID int OUTPUT
AS
BEGIN
IF EXISTS( SELECT ID FROM ITTESI_AssetTracker_Person WHERE Guid = @Guid)
BEGIN
SET @intPersonID = @@IDENTITY
END
ELSE
BEGIN
INSERT INTO ITTESI_AssetTracker_Person VALUES (@Guid,@FirstName,@LastName)
SET @intPersonID = @@IDENTITY
END
END
Thanks for your help.