I am rather new to stored procedures, can someone explain why when this executes and the conditions are met, I cannot return the results of the select statement to my code (ordinal not found error) but when the conditions aren't true it runs fine.
Thanks
CREATE PROCEDURE sp_selfenroll
AS
Declare @acCheck nvarchar(20)
Declare @Exists nvarchar(10)
Declare @Identity Int
Select @acCheck = AccountNumber From Customer Where AccountNumber = @accountnumber
If (@acCheck IS NULL) OR (@acCheck = '')
Begin
Insert Into table
Update another table
Set @Exists = 'False'
End
Else
Begin
Set @Exists = 'True'
End
SELECT @Exists as 'duplicate'
GO
Thanks
CREATE PROCEDURE sp_selfenroll
AS
Declare @acCheck nvarchar(20)
Declare @Exists nvarchar(10)
Declare @Identity Int
Select @acCheck = AccountNumber From Customer Where AccountNumber = @accountnumber
If (@acCheck IS NULL) OR (@acCheck = '')
Begin
Insert Into table
Update another table
Set @Exists = 'False'
End
Else
Begin
Set @Exists = 'True'
End
SELECT @Exists as 'duplicate'
GO