I am trying to use an input parameter as a table name in a stored proc. I am getting an error saying that the variable @dateid has not been declared.
Is there any way to use a table name that is dynamically created in the calling script and passed on to the sp as an input variable ?
CREATE PROCEDURE sp_ScoreCardsDrill1
@cocoid int,
@categoryid char (20),
@dateid char (20)
AS
SET NOCOUNT ON
IF @categoryid = 'NewClaims'
BEGIN
SELECT * FROM @dateid WHERE COCO_NO=@cocoid
END
GO
Thanks
Is there any way to use a table name that is dynamically created in the calling script and passed on to the sp as an input variable ?
CREATE PROCEDURE sp_ScoreCardsDrill1
@cocoid int,
@categoryid char (20),
@dateid char (20)
AS
SET NOCOUNT ON
IF @categoryid = 'NewClaims'
BEGIN
SELECT * FROM @dateid WHERE COCO_NO=@cocoid
END
GO
Thanks