doesn't make sense on the instance. E.g this can happen if you create the
'machine1\username' is invalid.
"bill k." <billk@discussions.microsoft.com> wrote in message
news:C5D80215-7CAB-4141-994D-87D12F2F957E@microsoft.com...
> Hi, Remus
>
> It says this is the reason. What is problem here and how to resolve it?
> Thank you,
>
> An exception occurred while enqueueing a message in the target queue.
> Error:
> 15517, State: 1. Cannot execute as the database principal because the
> principal "dbo" does not exist, this type of principal cannot be
> impersonated, or you do not have permission.
>
> "Remus Rusanu [MSFT]" wrote:
>
>> Check if the event is sitting in the sys.transmision_queue and cannot be
>> delivered. The transmission_status column should explain why it cannot be
>> delivered.
>>
>> HTH,
>> ~ Remus
>>
>> "bill k." <billk@discussions.microsoft.com> wrote in message
>> news:8ACEF0BE-CDC3-48A1-9BD2-3205681D9184@microsoft.com...
>> > Hi, I ran below to setup Event Notification but it did not seem to work
>> > (SELECT * FROM EventLog returns 0 row). Can you help?
>> >
>> > -- enable Service Broker
>> > USE AdventureWorks
>> > ALTER DATABASE AdventureWorks SET ENABLE_BROKER;
>> >
>> > -- drop and create the eventLog table
>> > IF exists (select * from dbo.sysobjects where id =
>> > object_id(N'dbo.EventLog') and OBJECTPROPERTY(id, N'IsTable') = 1)
>> > DROP TABLE dbo.EventLog
>> > GO
>> > CREATE TABLE EventLog
>> > (Command nvarchar(1000),
>> > PostTime nvarchar(24),
>> > HostName nvarchar(100),
>> > LoginName nvarchar(100)
>> > )
>> > GO
>> >
>> > -- create a queue
>> > CREATE QUEUE NotifyQueue
>> > GO
>> >
>> > -- create an event processing service
>> > CREATE SERVICE NotifyService
>> > ON QUEUE NotifyQueue
>> > (
>> > [
http://schemas.microsoft.com/SQL/Notifications/PostEventNotification]
>> > )
>> > GO
>> >
>> > -- create a route
>> > CREATE ROUTE NotifyRoute
>> > WITH SERVICE_NAME = 'NotifyService',
>> > ADDRESS = 'LOCAL'
>> > GO
>> >
>> >
>> > --create the database event notifications
>> > CREATE EVENT NOTIFICATION NotifyCREATE_TABLE
>> > ON DATABASE
>> > FOR CREATE_TABLE
>> > TO SERVICE 'NotifyService', 'current database'
>> > GO
>> >
>> > CREATE EVENT NOTIFICATION NotifyALTER_TABLE
>> > ON DATABASE
>> > FOR ALTER_TABLE
>> > TO SERVICE 'NotifyService', 'current database'
>> > GO
>> >
>> > --create a table
>> > CREATE TABLE T1 (col1 int)
>> > GO
>> >
>> > --process the event notifications
>> > DECLARE @messageTypeName nvarchar(256),
>> > @messageBody xml
>> > ;RECEIVE TOP(1)
>> > @messageTypeName = message_type_name,
>> > @messageBody = message_body
>> > FROM dbo.NotifyQueue;
>> >
>> > IF @@ROWCOUNT = 0
>> > RETURN
>> >
>> > PRINT CONVERT(nvarchar(1000),@messagebody)
>> >
>> > DECLARE @cmd nvarchar(1000)
>> > DECLARE @posttime nvarchar(24)
>> > DECLARE @spid nvarchar(6)
>> > DECLARE @hostname nvarchar(100)
>> > DECLARE @loginname nvarchar(100)
>> > SET @cmd = @messagebody.value
>> > ('(/EVENT_INSTANCE/TSQLCommand/CommandText)[1]',
>> > 'nvarchar(1000)')
>> > SET @posttime = @messagebody.value
>> > ('(/EVENT_INSTANCE/PostTime)[1]', 'nvarchar(24)')
>> > SET @spid = @messagebody.value
>> > ('(/EVENT_INSTANCE/SPID)[1]', 'nvarchar(6)')
>> > SET @loginname = @messagebody.value
>> > ('(/EVENT_INSTANCE/LoginName)[1]', 'nvarchar(100)')
>> > SET @hostname = HOST_NAME()
>> >
>> >
>> > INSERT INTO EventLog(Command,PostTime,HostName,LoginName)
>> > VALUES(@cmd, @posttime, @hostname, @loginname)
>> > GO
>> >
>> > SELECT * FROM EventLog
>>
>>
>>