stored procedure dynamic insert
Hello everybody, can anybody help me out, for the life of my I cannot get this to work or figure out why this thinks @iPrintBuyerID is a varchar, I have hard coded an int value in my input parameters. I am trying to create a dynamic Insert statement because I am have 3 tables but only the table name changes the fields are all the same, so if you have a better way of doing this I would love to know, as I cannot find anything on it anywhere I have even tried using CASE to do this, nothing seems to work.
Microsoft OLE DB Provider for SQL Server error '80040e07'
Syntax error converting the varchar value ' + @iPrintBuyerID + ' to a column of data type int.
CREATE PROCEDURE sp_ModifyGetBids_AddVendor
@NewBidID int OUTPUT
EXEC('INSERT INTO ' + @strTable +
' (Piece_ID_Bids, Vendor_ID_Bids, Rep_ID_Bids, Vendor_Notified, PrintBuyer_Bids) VALUES' +
' ('' + @iPieceID + '', '' + @iVendorID + '', '' + @iRepID + '', '' + @DateNotified + '', '' + @iPrintBuyerID + '')')
SELECT @NewBidID = @@IDENTITY