Working on a project that requires a procedure with a dynamic table name. Need to work out how to write an insert value query into the table. Not a massive project so overheads and such is not an issue.
Tried several variations however it always falls over.
DECLARE @DynamicTableName NVARCHAR(100)
SET @DynamicTableName = 'DynamicTableName'
INSERT @DynamicTableName
(
HolidayStartDate
, HolidayEndDate
, HolidayType
, HolidayTypeID
, StaffCode
, StaffName
, Notes
, FTE
, CreatedBy
, CreatedDate
, HolidayRequestID
)
VALUES
( @Para1,
@Para2,
@Para3,
@Para4,
@Para5,
@Para5,
@Para6,
@Para7,
@Para8,
@Para9,
@Para10
)
sp_executeSQL, this supports input parameters.