Hello,
I want to do different things depending on the returned value of a sql statement which counts records, but keep getting syntax errors.
My ultimate goal is to return True or False back to an ASP page - If the count of records is > 0 return True, if the count of records = 0 return False.
This is the transact sql I am using:
CREATE PROCEDURE [s_Check_Duplicate_Article]
@bDuplicate varchar(5) OUTPUT,
@ID integer,
@Title varchar(50)
AS
DECLARE @iFound integer
-- set iFound to the number of records matching the title
SELECT @iFound = "SELECT Count(ID) FROM t_Articles WHERE Title='"+@Title+"' AND ID<>"+@ID
IF @iFound > 0
SELECT @bDuplicate = "True"
ELSE
SELECT @bDuplicate = "False"
and the error happens on the SELECT @iFound = .... line.
Can someone tell me the correct way to do this??
TIA [sig]<p>Simon<br>[/sig]
I want to do different things depending on the returned value of a sql statement which counts records, but keep getting syntax errors.
My ultimate goal is to return True or False back to an ASP page - If the count of records is > 0 return True, if the count of records = 0 return False.
This is the transact sql I am using:
CREATE PROCEDURE [s_Check_Duplicate_Article]
@bDuplicate varchar(5) OUTPUT,
@ID integer,
@Title varchar(50)
AS
DECLARE @iFound integer
-- set iFound to the number of records matching the title
SELECT @iFound = "SELECT Count(ID) FROM t_Articles WHERE Title='"+@Title+"' AND ID<>"+@ID
IF @iFound > 0
SELECT @bDuplicate = "True"
ELSE
SELECT @bDuplicate = "False"
and the error happens on the SELECT @iFound = .... line.
Can someone tell me the correct way to do this??
TIA [sig]<p>Simon<br>[/sig]