I am trying to create a stored procedure in SQL Server 2008 which can insert data into any table (not table specific). I created one shown below, but during execution of the procedure an exception is thrown i.e.
Invalid object name 'dbo.@table'.
Stored procedure code:
CREATE PROCEDURE dbo.sp_InsertValues
@table varchar(15)
, @fields varchar(100)
, @values varchar(100)
AS
BEGIN
INSERT INTO [dbo].[@table] (@fields) VALUES (@values)
END
GO
Remember I checked the parameters table, columns and values parameters are not null.