I am trying to create a Stored Procedure, and pass the name of a table as a parameter and I get this message:Must declare the table variable "@tblName".
What do I have to change to make it work?
CREATE PROCEDURE [usp_SaveToErrorLog]
@tblName as nvarchar(50),
@subject as nvarchar(30)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(@tblName))
Begin
Insert Into @tblName
(ErrorNumber, ErrorMessage, ErrorProcedure, ErrorState, ErrorSeverity, ErrorLine)
Select
ERROR_NUMBER(), ERROR_MESSAGE(), ERROR_PROCEDURE(), ERROR_STATE(), ERROR_SEVERITY(), ERROR_LINE()
End
END