Click to See Complete Forum and Search --> : standard Stored Procedure


sr_aneesh
January 23rd, 2005, 11:34 AM
i want to make a standard stored procedure to check the duplication of records in anytable.
The fieldname and the tablename can vary...

my code is as follows wich gives the error : Err 137 ; Must declare the variable @tblname

CREATE PROCEDURE sp_checkdup
@tblname varchar(25),
@fldname varchar(25),
@fldval varchar(25),
@spname varchar(25)
AS
if exists (select @fldname from @tblname where @fldname=@fldval)
return 555
else
execute @spname
GO


what could be the problem .....

thanx in advance