I have a process that every 1st of the month creates a new table ie: CR200602 for Feb, 2006. I need to put a trigger on this table, not a problem, but then come March I have to do it again. So here is what I want to do.
Create a stored procedure, got that part done, but I cannot put in this:
CREATE TRIGGER trigger_name ON @NewTableName FOR INSERT
I have made these variables:
Set @Year = year(getdate())
Set @Month = cast (datepart(mm,getdate()) as varchar(2))
Set @NewTableName = 'CR' & @Year & @Month
This part works but I cannot get the variable into the CREATE statement.
Create a stored procedure, got that part done, but I cannot put in this:
CREATE TRIGGER trigger_name ON @NewTableName FOR INSERT
I have made these variables:
Set @Year = year(getdate())
Set @Month = cast (datepart(mm,getdate()) as varchar(2))
Set @NewTableName = 'CR' & @Year & @Month
This part works but I cannot get the variable into the CREATE statement.