Reputation: 936
I'm going mad on this one. I have the following SP:
ALTER PROCEDURE [BankImport].[spBI_getIsBatchUnique]
@batchName varchar = 500
AS
BEGIN
SET NOCOUNT ON;
IF (EXISTS (SELECT 1 FROM [ACN_Main].[BankImport].[tblBI_Jobs]
WHERE [batchNumber] = @batchName))
BEGIN
SELECT 1
END
ELSE
BEGIN
SELECT 0
END
END
GO
But whatever the request is, I always get back 0!
I tried to modify it in several ways but with no success! What I need to do is check if there is a record with that batch number and return true, otherwise return false.
Any tip?
Thanks
Upvotes: 1
Views: 147
Reputation: 28990
I think because you compare batchNumber and batchName, try
EXISTS (SELECT 1 FROM [ACN_Main].[BankImport].[tblBI_Jobs]
WHERE [batchName] = @batchName)
Upvotes: 1
Reputation: 18379
Your input parameter looks a bit funny
@batchName varchar = 500
Should it have been this?
@batchName varchar(500)
Ie set the length of the varchar datatype, how you currently have it, 500 is the default value for the batchName
param.
Upvotes: 8