I've reviewed (and tried to use) SQL Server 2008 trigger on create table without success. I currently upload a CSV file to a table called DataTMP. The data in this file is ETL'd into another table using a stored procedure, after which the DataTMP table is dropped.
What I'm looking to achieve is that when DataTMP is created, its creation triggers the execution of the stored procedure and following successful execution, the DataTMP table is dropped.
What I've tried is:
CREATE OR REPLACE TRIGGER trig_DataUpsert
AFTER CREATE ON SCHEMA
BEGIN
EXEC usp_data_ETL
DROP TABLE DataTMP
END
The error is suggested at 'OR' and again 'ON' in the trigger CREATE statement
I'm using SSMS v18
I'm not sure on SQL Server 2008, I don't have an instance to test, but as far as I'm aware, DDL triggers were available back then as well.
Please try this, or adapt to your situation: