DDL Server Trigger - SQL Agent
- From: dickster <grd@xxxxxxxxx>
- Date: Fri, 6 Jun 2008 09:39:30 -0700 (PDT)
I created this trigger.
ALTER TRIGGER ddl_trig_database ON ALL SERVER
AFTER CREATE_DATABASE
AS
DECLARE @DBNAME AS nvarchar(100);
SET @DBNAME = EVENTDATA().value('(/EVENT_INSTANCE/DatabaseName)
[1]','nvarchar(100)')
DECLARE @cmd NVARCHAR(512)
SET @cmd = 'sqlcmd -S BDA-RMSDB -d '+ @DBNAME +' -E -i \\share
\script.sql
EXEC MASTER..XP_CMDSHELL @cmd
GO
script.sql creates a table say
Then I call
CREATE DATABASE myDb WITH TRUSTWORTHY ON;
but i get the following error message:
Msg 4060, Level 11, State 1, Server INTERLAGOS, Line 1
Cannot open database "myDb" requested by the login. The login failed.
Msg 18456, Level 14, State 1, Server INTERLAGOS, Line 1
Login failed for user 'ACME\_srvrmssql'.
ACME\_srvrmssql - runs the SQL agent
Any ideas???
Help greatly appreciated
Dickster
.
- Follow-Ups:
- Re: DDL Server Trigger - SQL Agent
- From: Erland Sommarskog
- Re: DDL Server Trigger - SQL Agent
- Prev by Date: Protect MDF Only 1 user can access
- Next by Date: Re: Certificate Requirements for SQL Data Encryption
- Previous by thread: Protect MDF Only 1 user can access
- Next by thread: Re: DDL Server Trigger - SQL Agent
- Index(es):