I use MS SQL 2008 and I want to create a trigger in a database that is created dynamic.
Creating the database is called within a stored procedure of an other database and runs perfectly, but when I want to add a trigger or a stored procedure, the executing fails.
If I try to run the dynamiy SQL with an
EXEC('USE dbase
GO
CREATE TRIGGER [blah]
GO')
I get:
Wrong syntax near 'GO'
And if I remove the 'USE ...' the trigger will be created in the wrong database.
Is there a trick to avoid my problems?
Thx