justMarshall 0 Newbie Poster

Hello all. I'm trying to keep table structures in sync across 2 seperate databases on the same SQL server instance using a DDL trigger on ALTER_TABLE, CREATE_TABLE, DROP_TABLE. Using EVENTDATA() as shown below, I can catch the TSQL that fired the trigger, but I cannot figure out how to execute the TSQL command on the destination db from the trigger.

CREATE TRIGGER [ddl_Table_Schema_]
ON DATABASE
FOR ALTER_TABLE, CREATE_TABLE, DROP_TABLE

AS 

SELECT
EVENTDATA().value('(/EVENT_INSTANCE/TSQLCommand)[1]', 'nvarchar(max)')
;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.