Showing posts with label activation. Show all posts
Showing posts with label activation. Show all posts

Sunday, March 11, 2012

Activation/Security/Dynamic SQL Question

I will have a variety of different types of work that will come into my Service Broker queue and I'll likely have a stored procedure or two for each of the different types of work (ie. move order header, move items, move payment, etc.) What is required to be done in each of these steps may vary by the subsidiary and type of order coming in. My plan is to use exclusively stored procedures but to execute them dynamically using sp_executesql. I think I should use sp_executesql because that way I can have a config file (in xml) that I can store what stored procedures need to be called for which unit of work/order type/subsidiary. If I do this I should be able to easily configure each type of work to be done in a config file and let Service Broker handle the execution dynamically. As long as I keep the parameters the same for each of the stored procedures (I'm thinking maybe 4 or 5 parameters) and passing them to each of the stored procedures, this approach will allow me to dynamically configure Service Broker to do what it is supposed to do. I can pull what needs to be done out of the message that comes in with an XQuery expression on the config file. I know that I will have to configure my user (activation user) to be able to run sp_executesql and the security may be complex (especially since I'm using certificates). I can not use trusted databases. Are there any other considerations I should think about?

Gary

You should be able to execute dynamic SQL as well as impersonate database principals (using the 'EXECUTE AS' statement or clause) to call message type handlers from the activation stored procedure. If you stay within the database, your database does not have to be trustworthy.

Hope that helps,
Rushi

Activation procedure design

I've been experimenting with Service Broker and was surprised at one aspect of the design: the interface to Activation stored procedures.

I would have expected the queue to be a parameted passed to the procedure rather than having to hard code the queue query into the SP.

In a system with lots of queues it seems plausible that the same activation procedure might want to be used with several queues.

Any comments?

David.

Stored procedures are compiled into execution plans that bind strictly the rowsets being involved. That means that a stored procedure cannot be compiled to issue a RECEIVE (or SELECT for the matter) against a generic 'queue', but only agains a very specific <queue_name>. This is the same reason why one cannot write a SELECT where the table name is a @.variable. The only workaround, both in SELECT and in activation case, is to use dynamic SQL, with the likely cost of having to compile the dynamic SQL when the procedure executes.

Given this it would not make sense to have the queue name passed as a parameter, it is not a performant pattern. However, if you must, there is the trick to get the queue you were activated for from sys.dm_broker_activated_tasks and build dynamic SQL to RECEIVE the messages.

HTH,

~ Remus

Activation proc failed

Good day,

I have send a msg successful,but the proc failed. I altered the proc to correct the problem in the proc. The msg are still in the queue. Is there a manual way to excute the proc again to process the msg in the q? or do I wait for service broker to do it after a retry time (self recover)?

thank you in advance.

If the proc fails (i.e. throws an exception), Service Broker will try to restart the proc every 5 seconds. However, if your proc actually did a RECEIVE which was rolled back, then the rollback handler will detect this as a poisoned message and disable the queue. You can check this by doing:

select is_receive_enabled from sys.service_queues where name='YourQueue';

You can enable the queue by:

alter queue [YourQueue] with status = on;

|||

Rudhi

what I did :

receive top(1) @.receivedMsg = message_body,

@.h = conversation_handle,

@.msgType = message_type_name

from q111 -- wrong queue ,finger trouble.

In theLog file viewer :
The activated proc [dbo].[HandleRecieveMsg] running on queue EOGDB.dbo.q2eog output the following: 'Invalid object name 'q111'.'

So I corrected the proc to point to the correct queue.

I did as you said: "select is_receive_enabled from sys.service_queues where name='q2eog'; " q return a value of 1.

The message still is in the correct q after 5 seconds and longer.

Is there something else I can look or do?

|||

Okay I followed the steps in the help:

"Symptom: Activation Stored Procedures Do Not Run". And discovered that the proc I execute inside the RecieveProc fails.

(the proc I exec inside the recieving proc is proc reference a external assmbly)

Now my q is if a proc fails and the msg is allready retrieved from the queue, what happens to the msg? where does it go or the error msg?

|||

You can look at the state of the queue monitor:

select * from sys.dm_broker_queue_monitors;

If it is in 'NOTIFIED' state (which means, waiting for someone to do a RECEIVE), you can either reset the state by doing a RECEIVE or an ALTER QUEUE:

ALTER QUEUE [YourQueue] WITH STATUS = ON;

Hope that helps.

|||If you are doing that within a transaction scope, the transaction should rollback and the message should be put back into the queue.

Activation not working

Hi There

Everything works 100% until i activate my sp.

I specify to execute as 'dbo' in the alter queue statement. I also define the activated sp to execute as 'dbo'.

But i keep getting permission errors from my activated sp. i have tried to excute as 'sa' , i have even tried to write a job that excutes to stored procedure but it also get weird errors. Bottom line if i exceute the sp in management studio logged in as sa it works , but thorugh activation or a job nothing works, as 'dbo' or 'sa'.

?

Thanx

Hi there.

It seems the statement in my sp that has a permission problem is the get conversation group sattement.

So my activation on the queue does not work when i stipulate execute as 'dbo' or OWNER. I cannot assign execute as 'sa' i get the following error "The server principal "sa" is not able to access the database "OLTP1PRO" under the current security context". I have tried not to stipulate the execute as so taht it defaults to a sysadmin.

But i always get this error:

The user does not have permission to perform this action.

So i tried the following.

CREATE LOGIN QueueReader with password = 'T#ST123'

CREATE USER QueueReader for login QueueReader

grant receive on [ewx.co.za/Queue/ewx_sb_central_queue] to QueueReader

grant execute on dbo.CENTRAL_Queue_Processor to QueueReader

And chanegd the execute as to QueueReader, but is till get the same error.

I dunno what else to try, no matter hwat i do i cannot execute the get conversation group statement ?

Please help ?

|||anyone?|||

What error do you get if you manually invoke the procedure, from Management Studio, under the QueueReader user context?

executeasuser'QueueReader';

go

exec dbo.CENTRAL_Queue_Processor;

go

revert;

go

|||

Hi Remus

I get the same error as before. The user does not have permission to perform this action. Error number 297.

I have done more investigation, judging by the erro line number line it seems that the QueueReader user cannot read from

sys.dm_broker_activated_tasks.

However i am expecting these errors, the activated stored procedure has many inserts etc. SO basically i want the activated sp to run as dbo, i do not want to have to setup alot of permission for the user.

My biggest question is why does EXECUTE as 'dbo' or OWNER not work ? How can i get permission errors when it executes as dbo ?

So i make QueueReader dbo of the database and i still get the user doesnot have permission error, so it seems only sysadmin can select from the sys. views, however i am still stumped , since the dbo of the database is a sysadmin. If i login as the user who is the dbo i can execute it. But if i say execute as dbo i get the permission error, i am totally stumped ?

Thanx

|||

Ok so it seems that if i reference sis.dm views in my activated sp i have to make the execute as user a sysadmin, or grant that user select on the sys.dm views , is this correct?

However i am still interested to know why execute as dbo does nto work when the dbo is also a sysadmin?

Thanx Remus you rfeedabck will be greatly appreciated.

|||

Hi Remus

Lastly, it also mentions in Roger Wolters book that if you do not stipulate execute as for your activated sp it will execute in the backgrouond as a sysadmin. However if i do not stipulate execute as i still get the permission error ? So not sure what is happening there?

Thanx

|||

Execute as user is restricted to database context. sysadmin is a server context concept. An untrusted database cannot extend the context to the server. This topic is covered in my blog in these posts: http://blogs.msdn.com/remusrusanu/archive/2006/01/12/512085.aspx, http://blogs.msdn.com/remusrusanu/archive/2006/03/01/541882.aspx and http://blogs.msdn.com/remusrusanu/archive/2006/03/07/545508.aspx

The simplest solution is to mark the database as trustworthy.

HTH,
~ Remus

|||

Thanx Remus

The links were worth reading and the trustworthy worked.

Just as a matter of interrest , what is the best practice in a prouction environment when the activation proc requires sys.dm views. Do you make the queue reader user a sysadmin (must be a bad idea), or make the dbo of the database a sysadmin, or simply grant the user permission to the sys.dm views (probably best) ? In gerneral when the actvation proc must use these views what would you reccomend ?

|||

The safest option is code signing (as in the exaple in my link). Getting code siging righ is really hard, so if you can get away with trustworthy bit, is much more easier. sysadmin is not a requirement, the appropiate priviledges needed to be granted are AUTHENTICATE SERVER to the database dbo and VIEW SERVER STATE to the execute as user.

HTH,
~ Remus

|||

HI Remus

Great thanx , i thnk i will stick to trustworthy and the permission you specified, thanx very much

Activation not working

Hi There

Everything works 100% until i activate my sp.

I specify to execute as 'dbo' in the alter queue statement. I also define the activated sp to execute as 'dbo'.

But i keep getting permission errors from my activated sp. i have tried to excute as 'sa' , i have even tried to write a job that excutes to stored procedure but it also get weird errors. Bottom line if i exceute the sp in management studio logged in as sa it works , but thorugh activation or a job nothing works, as 'dbo' or 'sa'.

?

Thanx

Hi there.

It seems the statement in my sp that has a permission problem is the get conversation group sattement.

So my activation on the queue does not work when i stipulate execute as 'dbo' or OWNER. I cannot assign execute as 'sa' i get the following error "The server principal "sa" is not able to access the database "OLTP1PRO" under the current security context". I have tried not to stipulate the execute as so taht it defaults to a sysadmin.

But i always get this error:

The user does not have permission to perform this action.

So i tried the following.

CREATE LOGIN QueueReader with password = 'T#ST123'

CREATE USER QueueReader for login QueueReader

grant receive on [ewx.co.za/Queue/ewx_sb_central_queue] to QueueReader

grant execute on dbo.CENTRAL_Queue_Processor to QueueReader

And chanegd the execute as to QueueReader, but is till get the same error.

I dunno what else to try, no matter hwat i do i cannot execute the get conversation group statement ?

Please help ?

|||anyone?|||

What error do you get if you manually invoke the procedure, from Management Studio, under the QueueReader user context?

execute as user 'QueueReader';

go

exec dbo.CENTRAL_Queue_Processor;

go

revert;

go

|||

Hi Remus

I get the same error as before. The user does not have permission to perform this action. Error number 297.

I have done more investigation, judging by the erro line number line it seems that the QueueReader user cannot read from

sys.dm_broker_activated_tasks.

However i am expecting these errors, the activated stored procedure has many inserts etc. SO basically i want the activated sp to run as dbo, i do not want to have to setup alot of permission for the user.

My biggest question is why does EXECUTE as 'dbo' or OWNER not work ? How can i get permission errors when it executes as dbo ?

So i make QueueReader dbo of the database and i still get the user doesnot have permission error, so it seems only sysadmin can select from the sys. views, however i am still stumped , since the dbo of the database is a sysadmin. If i login as the user who is the dbo i can execute it. But if i say execute as dbo i get the permission error, i am totally stumped ?

Thanx

|||

Ok so it seems that if i reference sis.dm views in my activated sp i have to make the execute as user a sysadmin, or grant that user select on the sys.dm views , is this correct?

However i am still interested to know why execute as dbo does nto work when the dbo is also a sysadmin?

Thanx Remus you rfeedabck will be greatly appreciated.

|||

Hi Remus

Lastly, it also mentions in Roger Wolters book that if you do not stipulate execute as for your activated sp it will execute in the backgrouond as a sysadmin. However if i do not stipulate execute as i still get the permission error ? So not sure what is happening there?

Thanx

|||

Execute as user is restricted to database context. sysadmin is a server context concept. An untrusted database cannot extend the context to the server. This topic is covered in my blog in these posts: http://blogs.msdn.com/remusrusanu/archive/2006/01/12/512085.aspx, http://blogs.msdn.com/remusrusanu/archive/2006/03/01/541882.aspx and http://blogs.msdn.com/remusrusanu/archive/2006/03/07/545508.aspx

The simplest solution is to mark the database as trustworthy.

HTH,
~ Remus

|||

Thanx Remus

The links were worth reading and the trustworthy worked.

Just as a matter of interrest , what is the best practice in a prouction environment when the activation proc requires sys.dm views. Do you make the queue reader user a sysadmin (must be a bad idea), or make the dbo of the database a sysadmin, or simply grant the user permission to the sys.dm views (probably best) ? In gerneral when the actvation proc must use these views what would you reccomend ?

|||

The safest option is code signing (as in the exaple in my link). Getting code siging righ is really hard, so if you can get away with trustworthy bit, is much more easier. sysadmin is not a requirement, the appropiate priviledges needed to be granted are AUTHENTICATE SERVER to the database dbo and VIEW SERVER STATE to the execute as user.

HTH,
~ Remus

|||

HI Remus

Great thanx , i thnk i will stick to trustworthy and the permission you specified, thanx very much

Activation Failure

We recently upgraded SQL Server 2005 to SP 2 and now cannot implement Database mail. The message given is "Activation Failure" in the log. I have looked at the stored procedure "sp_sysmail_activate" and there is apparently a failure due to an invalid parameter. Can someone provide some direction regarding how to proceed?

Thanks.

could u pse post back the exact error from error log

Madhu

|||

Date 5/30/2007 9:36:02 AM
Log Database Mail (Database Mail Log)

Log ID 516
Last Modified 5/30/2007 9:36:02 AM
Last Modified By sa

Message
Activation failure.

I hope this helps.

Thank you.

|||

We have also recently upgraded to sql 2005 sp2 and are experiencing the same error.

Log Database Mail (Database Mail Log)

Log ID 139
Last Modified 6/7/2007 12:50:06 PM
Last Modified By sa

Message
Activation failure.

Does anyone have any suggestions on what be causing this problem and potential solutions.

Thanks

|||

FYI - I was trying to make this work on SQL Server Express and was getting the same error message.

This might be because it's not supported, according to: http://msdn2.microsoft.com/en-us/library/ms165636.aspx

I don't know, but thought I would share.

Cheers,

-Richard

|||

DBMail is not supported on the Express edition. Let me know if you're receiving this error for a !Express edition.

Cheers,

Dan

|||Did you have any luck with your database mail issue. I'm experiencing the same thing.|||

Hi,

I'm also having this issue - See here for my problem:

http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=1890943&SiteID=17

Wonder if anyone has a solution ?

Cheers

|||

We just upgraded to SQL2005 SP2 and since database mail will not function here as well. Any solutions to this issue?

Database Mail Logs:

Date 8/3/2007 7:00:07 PM
Log Database Mail (Database Mail Log)

Log ID 1646
Last Modified 8/3/2007 7:00:07 PM
Last Modified By sa

Message
Activation failure.

EventVwr Logs:

Event Type: Information

Event Source: MSSQLSERVER

Event Category: (2)

Event ID: 9724

Date: 8/6/2007

Time: 8:00:06 AM

User: N/A

Computer: SERVERNAME

Description:

The activated proc [dbo].[sp_sysmail_activate] running on queue msdb.dbo.ExternalMailQueue output the following: 'Error executing extended stored procedure: Invalid Parameter'

|||same problem here, anyone any ideas please?
|||

Same to...

Additional information: after runnig DatabaseMail90.exe manualy, at DataBaseMailLog I have 2 errors:

Code Snippet

Date 21.09.2007 15:04:58
Log Database Mail (Database Mail Log)

Log ID 224
Last Modified 21.09.2007 15:04:58
Last Modified By WEST\freeman

Message
Invalid XML message format received on the ExternalMailQueue. conversation_handle: 408F6968-3268-DC11-8ADE-0015171170E8. message_type_name: {//www.microsoft.com/databasemail/messages}SendMailStatus. message body:
http://schemas.microsoft.com/databasemail/responses ResponseTypes.xsd" xmlns:responses="http://schemas.microsoft.com/databasemail/responses">

Code Snippet

Date 21.09.2007 15:04:58
Log Database Mail (Database Mail Log)

Log ID 225
Process ID 2032
Last Modified 21.09.2007 15:04:58
Last Modified By WEST\freeman

Message
1) Exception Information
===================
Exception Type: System.Data.SqlClient.SqlException
Errors: System.Data.SqlClient.SqlErrorCollection
Class: 16
LineNumber: 1
Number: 6602
Procedure: sp_xml_preparedocument
Server: .
State: 2
Source: .Net SqlClient Data Provider
ErrorCode: -2146232060
Message: The error description is 'Switch from current encoding to specified encoding not supported.'.
The XML parse error 0xc00ce56f occurred on line number 1, near the XML text "<?xml version="1.0" encoding="utf-16"?>".
Data: System.Collections.ListDictionaryInternal
TargetSite: Void OnError(System.Data.SqlClient.SqlException, Boolean)
HelpLink: NULL

StackTrace Information
===================
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Microsoft.SqlServer.Management.SqlIMail.Server.DataAccess.DataAccessAdapter.PostResponse(Response r, Guid convHandle)
at Microsoft.SqlServer.Management.SqlIMail.IMailProcess.ThreadCallBack.PostResponseIfNeeded(MailInfo mi, Response r)
at Microsoft.SqlServer.Management.SqlIMail.IMailProcess.ThreadCallBack.MailOperation(Object o)

|||

Forgot Smile

After runnig DatabaseMail90.exe manual leters from DatabaseMail query will sent.

Activation Failure

We recently upgraded SQL Server 2005 to SP 2 and now cannot implement Database mail. The message given is "Activation Failure" in the log. I have looked at the stored procedure "sp_sysmail_activate" and there is apparently a failure due to an invalid parameter. Can someone provide some direction regarding how to proceed?

Thanks.

could u pse post back the exact error from error log

Madhu

|||

Date 5/30/2007 9:36:02 AM
Log Database Mail (Database Mail Log)

Log ID 516
Last Modified 5/30/2007 9:36:02 AM
Last Modified By sa

Message
Activation failure.

I hope this helps.

Thank you.

|||

We have also recently upgraded to sql 2005 sp2 and are experiencing the same error.

Log Database Mail (Database Mail Log)

Log ID 139
Last Modified 6/7/2007 12:50:06 PM
Last Modified By sa

Message
Activation failure.

Does anyone have any suggestions on what be causing this problem and potential solutions.

Thanks

|||

FYI - I was trying to make this work on SQL Server Express and was getting the same error message.

This might be because it's not supported, according to: http://msdn2.microsoft.com/en-us/library/ms165636.aspx

I don't know, but thought I would share.

Cheers,

-Richard

|||

DBMail is not supported on the Express edition. Let me know if you're receiving this error for a !Express edition.

Cheers,

Dan

|||Did you have any luck with your database mail issue. I'm experiencing the same thing.|||

Hi,

I'm also having this issue - See here for my problem:

http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=1890943&SiteID=17

Wonder if anyone has a solution ?

Cheers

|||

We just upgraded to SQL2005 SP2 and since database mail will not function here as well. Any solutions to this issue?

Database Mail Logs:

Date 8/3/2007 7:00:07 PM
Log Database Mail (Database Mail Log)

Log ID 1646
Last Modified 8/3/2007 7:00:07 PM
Last Modified By sa

Message
Activation failure.

EventVwr Logs:

Event Type: Information

Event Source: MSSQLSERVER

Event Category: (2)

Event ID: 9724

Date: 8/6/2007

Time: 8:00:06 AM

User: N/A

Computer: SERVERNAME

Description:

The activated proc [dbo].[sp_sysmail_activate] running on queue msdb.dbo.ExternalMailQueue output the following: 'Error executing extended stored procedure: Invalid Parameter'

|||same problem here, anyone any ideas please?
|||

Same to...

Additional information: after runnig DatabaseMail90.exe manualy, at DataBaseMailLog I have 2 errors:

Code Snippet

Date 21.09.2007 15:04:58
Log Database Mail (Database Mail Log)

Log ID 224
Last Modified 21.09.2007 15:04:58
Last Modified By WEST\freeman

Message
Invalid XML message format received on the ExternalMailQueue. conversation_handle: 408F6968-3268-DC11-8ADE-0015171170E8. message_type_name: {//www.microsoft.com/databasemail/messages}SendMailStatus. message body:
http://schemas.microsoft.com/databasemail/responses ResponseTypes.xsd" xmlns:responses="http://schemas.microsoft.com/databasemail/responses">

Code Snippet

Date 21.09.2007 15:04:58
Log Database Mail (Database Mail Log)

Log ID 225
Process ID 2032
Last Modified 21.09.2007 15:04:58
Last Modified By WEST\freeman

Message
1) Exception Information
===================
Exception Type: System.Data.SqlClient.SqlException
Errors: System.Data.SqlClient.SqlErrorCollection
Class: 16
LineNumber: 1
Number: 6602
Procedure: sp_xml_preparedocument
Server: .
State: 2
Source: .Net SqlClient Data Provider
ErrorCode: -2146232060
Message: The error description is 'Switch from current encoding to specified encoding not supported.'.
The XML parse error 0xc00ce56f occurred on line number 1, near the XML text "<?xml version="1.0" encoding="utf-16"?>".
Data: System.Collections.ListDictionaryInternal
TargetSite: Void OnError(System.Data.SqlClient.SqlException, Boolean)
HelpLink: NULL

StackTrace Information
===================
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Microsoft.SqlServer.Management.SqlIMail.Server.DataAccess.DataAccessAdapter.PostResponse(Response r, Guid convHandle)
at Microsoft.SqlServer.Management.SqlIMail.IMailProcess.ThreadCallBack.PostResponseIfNeeded(MailInfo mi, Response r)
at Microsoft.SqlServer.Management.SqlIMail.IMailProcess.ThreadCallBack.MailOperation(Object o)

|||

Forgot Smile

After runnig DatabaseMail90.exe manual leters from DatabaseMail query will sent.

|||

Why this happndes, i don't now. But solution is found/

This hapend, couse you stored proc msdb.dbo.sp_sysmail_activate is older, and mismatches procedure xp_sysmail_activate in databe master.

Run this code to update the sp_sysmail_activate proc.

sp_sysmail_activate

USE [msdb]

GO

/****** Object: StoredProcedure [dbo].[sp_sysmail_activate] Script Date: 09/27/2007 15:46:33 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

-- sp_sysmail_activate : Starts the DatabaseMail process if it isn't already running

--

ALTER PROCEDURE [dbo].[sp_sysmail_activate]

AS

BEGIN

DECLARE @.mailDbName sysname

DECLARE @.mailDbId INT

DECLARE @.mailEngineLifeMin INT

DECLARE @.loggingLevel nvarchar(256)

DECLARE @.loggingLevelInt int

DECLARE @.parameter_value nvarchar(256)

DECLARE @.localmessage nvarchar(max)

DECLARE @.readFromConfigFile INT

DECLARE @.rc INT

SET NOCOUNT ON

EXEC sp_executesql @.statement = N'RECEIVE TOP(0) * FROM msdb.dbo.ExternalMailQueue'

EXEC @.rc = msdb.dbo.sysmail_help_configure_value_sp @.parameter_name = N'DatabaseMailExeMinimumLifeTime',

@.parameter_value = @.parameter_value OUTPUT

IF(@.rc <> 0)

RETURN (1)

--ConvertToInt will return the default if @.parameter_value is null or config value can't be converted

--Setting max exe lifetime is 1 week (604800 secs). Can't see a reason for it to ever run longer that this

SET @.mailEngineLifeMin = dbo.ConvertToInt(@.parameter_value, 604800, 600)

EXEC msdb.dbo.sysmail_help_configure_value_sp @.parameter_name = N'ReadFromConfigurationFile',

@.parameter_value = @.parameter_value OUTPUT

--Try to read the optional read from configuration file:

SET @.readFromConfigFile = dbo.ConvertToInt(@.parameter_value, 1, 0)

--Try and get the optional logging level for the DatabaseMail process

EXEC msdb.dbo.sysmail_help_configure_value_sp @.parameter_name = N'LoggingLevel',

@.parameter_value = @.loggingLevel OUTPUT

--Convert logging level into string value for passing into XP

SET @.loggingLevelInt = dbo.ConvertToInt(@.loggingLevel, 3, 2)

IF @.loggingLevelInt = 1

SET @.loggingLevel = 'Normal'

ELSE IF @.loggingLevelInt = 3

SET @.loggingLevel = 'Verbose'

ELSE -- default

SET @.loggingLevel = 'Extended'

SET @.mailDbName = DB_NAME()

SET @.mailDbId = DB_ID()

EXEC @.rc = master..xp_sysmail_activate @.mailDbId, @.mailDbName, @.readFromConfigFile,

@.mailEngineLifeMin, @.loggingLevel

IF(@.rc <> 0)

BEGIN

SET @.localmessage = FORMATMESSAGE(14637)

exec msdb.dbo.sysmail_logmailevent_sp @.event_type=3, @.description=@.localmessage

END

ELSE

BEGIN

SET @.localmessage = FORMATMESSAGE(14638)

exec msdb.dbo.sysmail_logmailevent_sp @.event_type=0, @.description=@.localmessage

END

RETURN @.rc

END

|||

Also you must change this stored/procs:

msdb.dbo.sp_send_dbmail

msdb.dbo.sp_ExternalMailQueueListener

msdb.dbo.RunMailQuery

msdb.dbo.sysmail_verify_account_sp

msdb.dbo.sp_validate_user

Take it from worked server.

|||

I get this error too on standard edition SP2.

Has anyone reported this as a bug?

Activation Failure

We recently upgraded SQL Server 2005 to SP 2 and now cannot implement Database mail. The message given is "Activation Failure" in the log. I have looked at the stored procedure "sp_sysmail_activate" and there is apparently a failure due to an invalid parameter. Can someone provide some direction regarding how to proceed?

Thanks.

could u pse post back the exact error from error log

Madhu

|||

Date 5/30/2007 9:36:02 AM
Log Database Mail (Database Mail Log)

Log ID 516
Last Modified 5/30/2007 9:36:02 AM
Last Modified By sa

Message
Activation failure.

I hope this helps.

Thank you.

|||

We have also recently upgraded to sql 2005 sp2 and are experiencing the same error.

Log Database Mail (Database Mail Log)

Log ID 139
Last Modified 6/7/2007 12:50:06 PM
Last Modified By sa

Message
Activation failure.

Does anyone have any suggestions on what be causing this problem and potential solutions.

Thanks

|||

FYI - I was trying to make this work on SQL Server Express and was getting the same error message.

This might be because it's not supported, according to: http://msdn2.microsoft.com/en-us/library/ms165636.aspx

I don't know, but thought I would share.

Cheers,

-Richard

|||

DBMail is not supported on the Express edition. Let me know if you're receiving this error for a !Express edition.

Cheers,

Dan

|||Did you have any luck with your database mail issue. I'm experiencing the same thing.|||

Hi,

I'm also having this issue - See here for my problem:

http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=1890943&SiteID=17

Wonder if anyone has a solution ?

Cheers

|||

We just upgraded to SQL2005 SP2 and since database mail will not function here as well. Any solutions to this issue?

Database Mail Logs:

Date 8/3/2007 7:00:07 PM
Log Database Mail (Database Mail Log)

Log ID 1646
Last Modified 8/3/2007 7:00:07 PM
Last Modified By sa

Message
Activation failure.

EventVwr Logs:

Event Type: Information

Event Source: MSSQLSERVER

Event Category: (2)

Event ID: 9724

Date: 8/6/2007

Time: 8:00:06 AM

User: N/A

Computer: SERVERNAME

Description:

The activated proc [dbo].[sp_sysmail_activate] running on queue msdb.dbo.ExternalMailQueue output the following: 'Error executing extended stored procedure: Invalid Parameter'

|||same problem here, anyone any ideas please?

Activation Failure

We recently upgraded SQL Server 2005 to SP 2 and now cannot implement Database mail. The message given is "Activation Failure" in the log. I have looked at the stored procedure "sp_sysmail_activate" and there is apparently a failure due to an invalid parameter. Can someone provide some direction regarding how to proceed?

Thanks.

could u pse post back the exact error from error log

Madhu

|||

Date 5/30/2007 9:36:02 AM
Log Database Mail (Database Mail Log)

Log ID 516
Last Modified 5/30/2007 9:36:02 AM
Last Modified By sa

Message
Activation failure.

I hope this helps.

Thank you.

|||

We have also recently upgraded to sql 2005 sp2 and are experiencing the same error.

Log Database Mail (Database Mail Log)

Log ID 139
Last Modified 6/7/2007 12:50:06 PM
Last Modified By sa

Message
Activation failure.

Does anyone have any suggestions on what be causing this problem and potential solutions.

Thanks

|||

FYI - I was trying to make this work on SQL Server Express and was getting the same error message.

This might be because it's not supported, according to: http://msdn2.microsoft.com/en-us/library/ms165636.aspx

I don't know, but thought I would share.

Cheers,

-Richard

|||

DBMail is not supported on the Express edition. Let me know if you're receiving this error for a !Express edition.

Cheers,

Dan

|||Did you have any luck with your database mail issue. I'm experiencing the same thing.|||

Hi,

I'm also having this issue - See here for my problem:

http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=1890943&SiteID=17

Wonder if anyone has a solution ?

Cheers

|||

We just upgraded to SQL2005 SP2 and since database mail will not function here as well. Any solutions to this issue?

Database Mail Logs:

Date 8/3/2007 7:00:07 PM
Log Database Mail (Database Mail Log)

Log ID 1646
Last Modified 8/3/2007 7:00:07 PM
Last Modified By sa

Message
Activation failure.

EventVwr Logs:

Event Type: Information

Event Source: MSSQLSERVER

Event Category: (2)

Event ID: 9724

Date: 8/6/2007

Time: 8:00:06 AM

User: N/A

Computer: SERVERNAME

Description:

The activated proc [dbo].[sp_sysmail_activate] running on queue msdb.dbo.ExternalMailQueue output the following: 'Error executing extended stored procedure: Invalid Parameter'

|||same problem here, anyone any ideas please?
|||

Same to...

Additional information: after runnig DatabaseMail90.exe manualy, at DataBaseMailLog I have 2 errors:

Code Snippet

Date 21.09.2007 15:04:58
Log Database Mail (Database Mail Log)

Log ID 224
Last Modified 21.09.2007 15:04:58
Last Modified By WEST\freeman

Message
Invalid XML message format received on the ExternalMailQueue. conversation_handle: 408F6968-3268-DC11-8ADE-0015171170E8. message_type_name: {//www.microsoft.com/databasemail/messages}SendMailStatus. message body:
http://schemas.microsoft.com/databasemail/responses ResponseTypes.xsd" xmlns:responses="http://schemas.microsoft.com/databasemail/responses">

Code Snippet

Date 21.09.2007 15:04:58
Log Database Mail (Database Mail Log)

Log ID 225
Process ID 2032
Last Modified 21.09.2007 15:04:58
Last Modified By WEST\freeman

Message
1) Exception Information
===================
Exception Type: System.Data.SqlClient.SqlException
Errors: System.Data.SqlClient.SqlErrorCollection
Class: 16
LineNumber: 1
Number: 6602
Procedure: sp_xml_preparedocument
Server: .
State: 2
Source: .Net SqlClient Data Provider
ErrorCode: -2146232060
Message: The error description is 'Switch from current encoding to specified encoding not supported.'.
The XML parse error 0xc00ce56f occurred on line number 1, near the XML text "<?xml version="1.0" encoding="utf-16"?>".
Data: System.Collections.ListDictionaryInternal
TargetSite: Void OnError(System.Data.SqlClient.SqlException, Boolean)
HelpLink: NULL

StackTrace Information
===================
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Microsoft.SqlServer.Management.SqlIMail.Server.DataAccess.DataAccessAdapter.PostResponse(Response r, Guid convHandle)
at Microsoft.SqlServer.Management.SqlIMail.IMailProcess.ThreadCallBack.PostResponseIfNeeded(MailInfo mi, Response r)
at Microsoft.SqlServer.Management.SqlIMail.IMailProcess.ThreadCallBack.MailOperation(Object o)

|||

Forgot Smile

After runnig DatabaseMail90.exe manual leters from DatabaseMail query will sent.

|||

Why this happndes, i don't now. But solution is found/

This hapend, couse you stored proc msdb.dbo.sp_sysmail_activate is older, and mismatches procedure xp_sysmail_activate in databe master.

Run this code to update the sp_sysmail_activate proc.

sp_sysmail_activate

USE [msdb]

GO

/****** Object: StoredProcedure [dbo].[sp_sysmail_activate] Script Date: 09/27/2007 15:46:33 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

-- sp_sysmail_activate : Starts the DatabaseMail process if it isn't already running

--

ALTER PROCEDURE [dbo].[sp_sysmail_activate]

AS

BEGIN

DECLARE @.mailDbName sysname

DECLARE @.mailDbId INT

DECLARE @.mailEngineLifeMin INT

DECLARE @.loggingLevel nvarchar(256)

DECLARE @.loggingLevelInt int

DECLARE @.parameter_value nvarchar(256)

DECLARE @.localmessage nvarchar(max)

DECLARE @.readFromConfigFile INT

DECLARE @.rc INT

SET NOCOUNT ON

EXEC sp_executesql @.statement = N'RECEIVE TOP(0) * FROM msdb.dbo.ExternalMailQueue'

EXEC @.rc = msdb.dbo.sysmail_help_configure_value_sp @.parameter_name = N'DatabaseMailExeMinimumLifeTime',

@.parameter_value = @.parameter_value OUTPUT

IF(@.rc <> 0)

RETURN (1)

--ConvertToInt will return the default if @.parameter_value is null or config value can't be converted

--Setting max exe lifetime is 1 week (604800 secs). Can't see a reason for it to ever run longer that this

SET @.mailEngineLifeMin = dbo.ConvertToInt(@.parameter_value, 604800, 600)

EXEC msdb.dbo.sysmail_help_configure_value_sp @.parameter_name = N'ReadFromConfigurationFile',

@.parameter_value = @.parameter_value OUTPUT

--Try to read the optional read from configuration file:

SET @.readFromConfigFile = dbo.ConvertToInt(@.parameter_value, 1, 0)

--Try and get the optional logging level for the DatabaseMail process

EXEC msdb.dbo.sysmail_help_configure_value_sp @.parameter_name = N'LoggingLevel',

@.parameter_value = @.loggingLevel OUTPUT

--Convert logging level into string value for passing into XP

SET @.loggingLevelInt = dbo.ConvertToInt(@.loggingLevel, 3, 2)

IF @.loggingLevelInt = 1

SET @.loggingLevel = 'Normal'

ELSE IF @.loggingLevelInt = 3

SET @.loggingLevel = 'Verbose'

ELSE -- default

SET @.loggingLevel = 'Extended'

SET @.mailDbName = DB_NAME()

SET @.mailDbId = DB_ID()

EXEC @.rc = master..xp_sysmail_activate @.mailDbId, @.mailDbName, @.readFromConfigFile,

@.mailEngineLifeMin, @.loggingLevel

IF(@.rc <> 0)

BEGIN

SET @.localmessage = FORMATMESSAGE(14637)

exec msdb.dbo.sysmail_logmailevent_sp @.event_type=3, @.description=@.localmessage

END

ELSE

BEGIN

SET @.localmessage = FORMATMESSAGE(14638)

exec msdb.dbo.sysmail_logmailevent_sp @.event_type=0, @.description=@.localmessage

END

RETURN @.rc

END

|||

Also you must change this stored/procs:

msdb.dbo.sp_send_dbmail

msdb.dbo.sp_ExternalMailQueueListener

msdb.dbo.RunMailQuery

msdb.dbo.sysmail_verify_account_sp

msdb.dbo.sp_validate_user

Take it from worked server.

|||

I get this error too on standard edition SP2.

Has anyone reported this as a bug?

Activation Failure

We recently upgraded SQL Server 2005 to SP 2 and now cannot implement Database mail. The message given is "Activation Failure" in the log. I have looked at the stored procedure "sp_sysmail_activate" and there is apparently a failure due to an invalid parameter. Can someone provide some direction regarding how to proceed?

Thanks.

could u pse post back the exact error from error log

Madhu

|||

Date 5/30/2007 9:36:02 AM
Log Database Mail (Database Mail Log)

Log ID 516
Last Modified 5/30/2007 9:36:02 AM
Last Modified By sa

Message
Activation failure.

I hope this helps.

Thank you.

|||

We have also recently upgraded to sql 2005 sp2 and are experiencing the same error.

Log Database Mail (Database Mail Log)

Log ID 139
Last Modified 6/7/2007 12:50:06 PM
Last Modified By sa

Message
Activation failure.

Does anyone have any suggestions on what be causing this problem and potential solutions.

Thanks

|||

FYI - I was trying to make this work on SQL Server Express and was getting the same error message.

This might be because it's not supported, according to: http://msdn2.microsoft.com/en-us/library/ms165636.aspx

I don't know, but thought I would share.

Cheers,

-Richard

|||

DBMail is not supported on the Express edition. Let me know if you're receiving this error for a !Express edition.

Cheers,

Dan

|||Did you have any luck with your database mail issue. I'm experiencing the same thing.|||

Hi,

I'm also having this issue - See here for my problem:

http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=1890943&SiteID=17

Wonder if anyone has a solution ?

Cheers

|||

We just upgraded to SQL2005 SP2 and since database mail will not function here as well. Any solutions to this issue?

Database Mail Logs:

Date 8/3/2007 7:00:07 PM
Log Database Mail (Database Mail Log)

Log ID 1646
Last Modified 8/3/2007 7:00:07 PM
Last Modified By sa

Message
Activation failure.

EventVwr Logs:

Event Type: Information

Event Source: MSSQLSERVER

Event Category: (2)

Event ID: 9724

Date: 8/6/2007

Time: 8:00:06 AM

User: N/A

Computer: SERVERNAME

Description:

The activated proc [dbo].[sp_sysmail_activate] running on queue msdb.dbo.ExternalMailQueue output the following: 'Error executing extended stored procedure: Invalid Parameter'

|||same problem here, anyone any ideas please?
|||

Same to...

Additional information: after runnig DatabaseMail90.exe manualy, at DataBaseMailLog I have 2 errors:

Code Snippet

Date 21.09.2007 15:04:58
Log Database Mail (Database Mail Log)

Log ID 224
Last Modified 21.09.2007 15:04:58
Last Modified By WEST\freeman

Message
Invalid XML message format received on the ExternalMailQueue. conversation_handle: 408F6968-3268-DC11-8ADE-0015171170E8. message_type_name: {//www.microsoft.com/databasemail/messages}SendMailStatus. message body:
http://schemas.microsoft.com/databasemail/responses ResponseTypes.xsd" xmlns:responses="http://schemas.microsoft.com/databasemail/responses">

Code Snippet

Date 21.09.2007 15:04:58
Log Database Mail (Database Mail Log)

Log ID 225
Process ID 2032
Last Modified 21.09.2007 15:04:58
Last Modified By WEST\freeman

Message
1) Exception Information
===================
Exception Type: System.Data.SqlClient.SqlException
Errors: System.Data.SqlClient.SqlErrorCollection
Class: 16
LineNumber: 1
Number: 6602
Procedure: sp_xml_preparedocument
Server: .
State: 2
Source: .Net SqlClient Data Provider
ErrorCode: -2146232060
Message: The error description is 'Switch from current encoding to specified encoding not supported.'.
The XML parse error 0xc00ce56f occurred on line number 1, near the XML text "<?xml version="1.0" encoding="utf-16"?>".
Data: System.Collections.ListDictionaryInternal
TargetSite: Void OnError(System.Data.SqlClient.SqlException, Boolean)
HelpLink: NULL

StackTrace Information
===================
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Microsoft.SqlServer.Management.SqlIMail.Server.DataAccess.DataAccessAdapter.PostResponse(Response r, Guid convHandle)
at Microsoft.SqlServer.Management.SqlIMail.IMailProcess.ThreadCallBack.PostResponseIfNeeded(MailInfo mi, Response r)
at Microsoft.SqlServer.Management.SqlIMail.IMailProcess.ThreadCallBack.MailOperation(Object o)

|||

Forgot Smile

After runnig DatabaseMail90.exe manual leters from DatabaseMail query will sent.

|||

Why this happndes, i don't now. But solution is found/

This hapend, couse you stored proc msdb.dbo.sp_sysmail_activate is older, and mismatches procedure xp_sysmail_activate in databe master.

Run this code to update the sp_sysmail_activate proc.

sp_sysmail_activate

USE [msdb]

GO

/****** Object: StoredProcedure [dbo].[sp_sysmail_activate] Script Date: 09/27/2007 15:46:33 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

-- sp_sysmail_activate : Starts the DatabaseMail process if it isn't already running

--

ALTER PROCEDURE [dbo].[sp_sysmail_activate]

AS

BEGIN

DECLARE @.mailDbName sysname

DECLARE @.mailDbId INT

DECLARE @.mailEngineLifeMin INT

DECLARE @.loggingLevel nvarchar(256)

DECLARE @.loggingLevelInt int

DECLARE @.parameter_value nvarchar(256)

DECLARE @.localmessage nvarchar(max)

DECLARE @.readFromConfigFile INT

DECLARE @.rc INT

SET NOCOUNT ON

EXEC sp_executesql @.statement = N'RECEIVE TOP(0) * FROM msdb.dbo.ExternalMailQueue'

EXEC @.rc = msdb.dbo.sysmail_help_configure_value_sp @.parameter_name = N'DatabaseMailExeMinimumLifeTime',

@.parameter_value = @.parameter_value OUTPUT

IF(@.rc <> 0)

RETURN (1)

--ConvertToInt will return the default if @.parameter_value is null or config value can't be converted

--Setting max exe lifetime is 1 week (604800 secs). Can't see a reason for it to ever run longer that this

SET @.mailEngineLifeMin = dbo.ConvertToInt(@.parameter_value, 604800, 600)

EXEC msdb.dbo.sysmail_help_configure_value_sp @.parameter_name = N'ReadFromConfigurationFile',

@.parameter_value = @.parameter_value OUTPUT

--Try to read the optional read from configuration file:

SET @.readFromConfigFile = dbo.ConvertToInt(@.parameter_value, 1, 0)

--Try and get the optional logging level for the DatabaseMail process

EXEC msdb.dbo.sysmail_help_configure_value_sp @.parameter_name = N'LoggingLevel',

@.parameter_value = @.loggingLevel OUTPUT

--Convert logging level into string value for passing into XP

SET @.loggingLevelInt = dbo.ConvertToInt(@.loggingLevel, 3, 2)

IF @.loggingLevelInt = 1

SET @.loggingLevel = 'Normal'

ELSE IF @.loggingLevelInt = 3

SET @.loggingLevel = 'Verbose'

ELSE -- default

SET @.loggingLevel = 'Extended'

SET @.mailDbName = DB_NAME()

SET @.mailDbId = DB_ID()

EXEC @.rc = master..xp_sysmail_activate @.mailDbId, @.mailDbName, @.readFromConfigFile,

@.mailEngineLifeMin, @.loggingLevel

IF(@.rc <> 0)

BEGIN

SET @.localmessage = FORMATMESSAGE(14637)

exec msdb.dbo.sysmail_logmailevent_sp @.event_type=3, @.description=@.localmessage

END

ELSE

BEGIN

SET @.localmessage = FORMATMESSAGE(14638)

exec msdb.dbo.sysmail_logmailevent_sp @.event_type=0, @.description=@.localmessage

END

RETURN @.rc

END

|||

Also you must change this stored/procs:

msdb.dbo.sp_send_dbmail

msdb.dbo.sp_ExternalMailQueueListener

msdb.dbo.RunMailQuery

msdb.dbo.sysmail_verify_account_sp

msdb.dbo.sp_validate_user

Take it from worked server.

|||

I get this error too on standard edition SP2.

Has anyone reported this as a bug?

Activation Failure

We recently upgraded SQL Server 2005 to SP 2 and now cannot implement Database mail. The message given is "Activation Failure" in the log. I have looked at the stored procedure "sp_sysmail_activate" and there is apparently a failure due to an invalid parameter. Can someone provide some direction regarding how to proceed?

Thanks.

could u pse post back the exact error from error log

Madhu

|||

Date 5/30/2007 9:36:02 AM
Log Database Mail (Database Mail Log)

Log ID 516
Last Modified 5/30/2007 9:36:02 AM
Last Modified By sa

Message
Activation failure.

I hope this helps.

Thank you.

|||

We have also recently upgraded to sql 2005 sp2 and are experiencing the same error.

Log Database Mail (Database Mail Log)

Log ID 139
Last Modified 6/7/2007 12:50:06 PM
Last Modified By sa

Message
Activation failure.

Does anyone have any suggestions on what be causing this problem and potential solutions.

Thanks

|||

FYI - I was trying to make this work on SQL Server Express and was getting the same error message.

This might be because it's not supported, according to: http://msdn2.microsoft.com/en-us/library/ms165636.aspx

I don't know, but thought I would share.

Cheers,

-Richard

|||

DBMail is not supported on the Express edition. Let me know if you're receiving this error for a !Express edition.

Cheers,

Dan

|||Did you have any luck with your database mail issue. I'm experiencing the same thing.|||

Hi,

I'm also having this issue - See here for my problem:

http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=1890943&SiteID=17

Wonder if anyone has a solution ?

Cheers

|||

We just upgraded to SQL2005 SP2 and since database mail will not function here as well. Any solutions to this issue?

Database Mail Logs:

Date 8/3/2007 7:00:07 PM
Log Database Mail (Database Mail Log)

Log ID 1646
Last Modified 8/3/2007 7:00:07 PM
Last Modified By sa

Message
Activation failure.

EventVwr Logs:

Event Type: Information

Event Source: MSSQLSERVER

Event Category: (2)

Event ID: 9724

Date: 8/6/2007

Time: 8:00:06 AM

User: N/A

Computer: SERVERNAME

Description:

The activated proc [dbo].[sp_sysmail_activate] running on queue msdb.dbo.ExternalMailQueue output the following: 'Error executing extended stored procedure: Invalid Parameter'

|||same problem here, anyone any ideas please?
|||

Same to...

Additional information: after runnig DatabaseMail90.exe manualy, at DataBaseMailLog I have 2 errors:

Code Snippet

Date 21.09.2007 15:04:58
Log Database Mail (Database Mail Log)

Log ID 224
Last Modified 21.09.2007 15:04:58
Last Modified By WEST\freeman

Message
Invalid XML message format received on the ExternalMailQueue. conversation_handle: 408F6968-3268-DC11-8ADE-0015171170E8. message_type_name: {//www.microsoft.com/databasemail/messages}SendMailStatus. message body:
http://schemas.microsoft.com/databasemail/responses ResponseTypes.xsd" xmlns:responses="http://schemas.microsoft.com/databasemail/responses">

Code Snippet

Date 21.09.2007 15:04:58
Log Database Mail (Database Mail Log)

Log ID 225
Process ID 2032
Last Modified 21.09.2007 15:04:58
Last Modified By WEST\freeman

Message
1) Exception Information
===================
Exception Type: System.Data.SqlClient.SqlException
Errors: System.Data.SqlClient.SqlErrorCollection
Class: 16
LineNumber: 1
Number: 6602
Procedure: sp_xml_preparedocument
Server: .
State: 2
Source: .Net SqlClient Data Provider
ErrorCode: -2146232060
Message: The error description is 'Switch from current encoding to specified encoding not supported.'.
The XML parse error 0xc00ce56f occurred on line number 1, near the XML text "<?xml version="1.0" encoding="utf-16"?>".
Data: System.Collections.ListDictionaryInternal
TargetSite: Void OnError(System.Data.SqlClient.SqlException, Boolean)
HelpLink: NULL

StackTrace Information
===================
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Microsoft.SqlServer.Management.SqlIMail.Server.DataAccess.DataAccessAdapter.PostResponse(Response r, Guid convHandle)
at Microsoft.SqlServer.Management.SqlIMail.IMailProcess.ThreadCallBack.PostResponseIfNeeded(MailInfo mi, Response r)
at Microsoft.SqlServer.Management.SqlIMail.IMailProcess.ThreadCallBack.MailOperation(Object o)

|||

Forgot Smile

After runnig DatabaseMail90.exe manual leters from DatabaseMail query will sent.

|||

Why this happndes, i don't now. But solution is found/

This hapend, couse you stored proc msdb.dbo.sp_sysmail_activate is older, and mismatches procedure xp_sysmail_activate in databe master.

Run this code to update the sp_sysmail_activate proc.

sp_sysmail_activate

USE [msdb]

GO

/****** Object: StoredProcedure [dbo].[sp_sysmail_activate] Script Date: 09/27/2007 15:46:33 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

-- sp_sysmail_activate : Starts the DatabaseMail process if it isn't already running

--

ALTER PROCEDURE [dbo].[sp_sysmail_activate]

AS

BEGIN

DECLARE @.mailDbName sysname

DECLARE @.mailDbId INT

DECLARE @.mailEngineLifeMin INT

DECLARE @.loggingLevel nvarchar(256)

DECLARE @.loggingLevelInt int

DECLARE @.parameter_value nvarchar(256)

DECLARE @.localmessage nvarchar(max)

DECLARE @.readFromConfigFile INT

DECLARE @.rc INT

SET NOCOUNT ON

EXEC sp_executesql @.statement = N'RECEIVE TOP(0) * FROM msdb.dbo.ExternalMailQueue'

EXEC @.rc = msdb.dbo.sysmail_help_configure_value_sp @.parameter_name = N'DatabaseMailExeMinimumLifeTime',

@.parameter_value = @.parameter_value OUTPUT

IF(@.rc <> 0)

RETURN (1)

--ConvertToInt will return the default if @.parameter_value is null or config value can't be converted

--Setting max exe lifetime is 1 week (604800 secs). Can't see a reason for it to ever run longer that this

SET @.mailEngineLifeMin = dbo.ConvertToInt(@.parameter_value, 604800, 600)

EXEC msdb.dbo.sysmail_help_configure_value_sp @.parameter_name = N'ReadFromConfigurationFile',

@.parameter_value = @.parameter_value OUTPUT

--Try to read the optional read from configuration file:

SET @.readFromConfigFile = dbo.ConvertToInt(@.parameter_value, 1, 0)

--Try and get the optional logging level for the DatabaseMail process

EXEC msdb.dbo.sysmail_help_configure_value_sp @.parameter_name = N'LoggingLevel',

@.parameter_value = @.loggingLevel OUTPUT

--Convert logging level into string value for passing into XP

SET @.loggingLevelInt = dbo.ConvertToInt(@.loggingLevel, 3, 2)

IF @.loggingLevelInt = 1

SET @.loggingLevel = 'Normal'

ELSE IF @.loggingLevelInt = 3

SET @.loggingLevel = 'Verbose'

ELSE -- default

SET @.loggingLevel = 'Extended'

SET @.mailDbName = DB_NAME()

SET @.mailDbId = DB_ID()

EXEC @.rc = master..xp_sysmail_activate @.mailDbId, @.mailDbName, @.readFromConfigFile,

@.mailEngineLifeMin, @.loggingLevel

IF(@.rc <> 0)

BEGIN

SET @.localmessage = FORMATMESSAGE(14637)

exec msdb.dbo.sysmail_logmailevent_sp @.event_type=3, @.description=@.localmessage

END

ELSE

BEGIN

SET @.localmessage = FORMATMESSAGE(14638)

exec msdb.dbo.sysmail_logmailevent_sp @.event_type=0, @.description=@.localmessage

END

RETURN @.rc

END

|||

Also you must change this stored/procs:

msdb.dbo.sp_send_dbmail

msdb.dbo.sp_ExternalMailQueueListener

msdb.dbo.RunMailQuery

msdb.dbo.sysmail_verify_account_sp

msdb.dbo.sp_validate_user

Take it from worked server.

|||

I get this error too on standard edition SP2.

Has anyone reported this as a bug?

Activation Failure

We recently upgraded SQL Server 2005 to SP 2 and now cannot implement Database mail. The message given is "Activation Failure" in the log. I have looked at the stored procedure "sp_sysmail_activate" and there is apparently a failure due to an invalid parameter. Can someone provide some direction regarding how to proceed?

Thanks.

could u pse post back the exact error from error log

Madhu

|||

Date 5/30/2007 9:36:02 AM
Log Database Mail (Database Mail Log)

Log ID 516
Last Modified 5/30/2007 9:36:02 AM
Last Modified By sa

Message
Activation failure.

I hope this helps.

Thank you.

|||

We have also recently upgraded to sql 2005 sp2 and are experiencing the same error.

Log Database Mail (Database Mail Log)

Log ID 139
Last Modified 6/7/2007 12:50:06 PM
Last Modified By sa

Message
Activation failure.

Does anyone have any suggestions on what be causing this problem and potential solutions.

Thanks

|||

FYI - I was trying to make this work on SQL Server Express and was getting the same error message.

This might be because it's not supported, according to: http://msdn2.microsoft.com/en-us/library/ms165636.aspx

I don't know, but thought I would share.

Cheers,

-Richard

|||

DBMail is not supported on the Express edition. Let me know if you're receiving this error for a !Express edition.

Cheers,

Dan

|||Did you have any luck with your database mail issue. I'm experiencing the same thing.|||

Hi,

I'm also having this issue - See here for my problem:

http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=1890943&SiteID=17

Wonder if anyone has a solution ?

Cheers

|||

We just upgraded to SQL2005 SP2 and since database mail will not function here as well. Any solutions to this issue?

Database Mail Logs:

Date 8/3/2007 7:00:07 PM
Log Database Mail (Database Mail Log)

Log ID 1646
Last Modified 8/3/2007 7:00:07 PM
Last Modified By sa

Message
Activation failure.

EventVwr Logs:

Event Type: Information

Event Source: MSSQLSERVER

Event Category: (2)

Event ID: 9724

Date: 8/6/2007

Time: 8:00:06 AM

User: N/A

Computer: SERVERNAME

Description:

The activated proc [dbo].[sp_sysmail_activate] running on queue msdb.dbo.ExternalMailQueue output the following: 'Error executing extended stored procedure: Invalid Parameter'

|||same problem here, anyone any ideas please?
|||

Same to...

Additional information: after runnig DatabaseMail90.exe manualy, at DataBaseMailLog I have 2 errors:

Code Snippet

Date 21.09.2007 15:04:58
Log Database Mail (Database Mail Log)

Log ID 224
Last Modified 21.09.2007 15:04:58
Last Modified By WEST\freeman

Message
Invalid XML message format received on the ExternalMailQueue. conversation_handle: 408F6968-3268-DC11-8ADE-0015171170E8. message_type_name: {//www.microsoft.com/databasemail/messages}SendMailStatus. message body:
http://schemas.microsoft.com/databasemail/responses ResponseTypes.xsd" xmlns:responses="http://schemas.microsoft.com/databasemail/responses">

Code Snippet

Date 21.09.2007 15:04:58
Log Database Mail (Database Mail Log)

Log ID 225
Process ID 2032
Last Modified 21.09.2007 15:04:58
Last Modified By WEST\freeman

Message
1) Exception Information
===================
Exception Type: System.Data.SqlClient.SqlException
Errors: System.Data.SqlClient.SqlErrorCollection
Class: 16
LineNumber: 1
Number: 6602
Procedure: sp_xml_preparedocument
Server: .
State: 2
Source: .Net SqlClient Data Provider
ErrorCode: -2146232060
Message: The error description is 'Switch from current encoding to specified encoding not supported.'.
The XML parse error 0xc00ce56f occurred on line number 1, near the XML text "<?xml version="1.0" encoding="utf-16"?>".
Data: System.Collections.ListDictionaryInternal
TargetSite: Void OnError(System.Data.SqlClient.SqlException, Boolean)
HelpLink: NULL

StackTrace Information
===================
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Microsoft.SqlServer.Management.SqlIMail.Server.DataAccess.DataAccessAdapter.PostResponse(Response r, Guid convHandle)
at Microsoft.SqlServer.Management.SqlIMail.IMailProcess.ThreadCallBack.PostResponseIfNeeded(MailInfo mi, Response r)
at Microsoft.SqlServer.Management.SqlIMail.IMailProcess.ThreadCallBack.MailOperation(Object o)

|||

Forgot Smile

After runnig DatabaseMail90.exe manual leters from DatabaseMail query will sent.

Activation

I was testing around with a sample service broker app using activation, and came across an interesting question. The little app sends a series of four messages to a queue, either on the same conversation or on seperate ones. Each message invokes one stored procedure in my activation procedure. All the procedure does is enter a record into a test table and then wait for an allotted amount of time. In my example, the first message called a proc that waited 20 sec, the 2nd one that waited 10 seconds, the third 5 seconds, and the 4th 1 second. I am using internal activation on the queue. It seemed that in both scenarios (sending on 4 separate conversations and on one conversation) the procedures executed "almost" sequentially. "Almost" meaning that the first procedure was done before the last one started executing. It makes sense to me that this would happen where I sent them on the same conversation, but not really when I sent them on 4 seperate ones. Is it because when I call a procedure from my activation procedure it locks the queue so that another message cannot be processed (I'm processing a message at a time)? How could I make it so that the 4th procedure (the one that only waits 1 second) returns before the 1st procedure (the one that waits 20 seconds)?MAX_QUEUE_READERS = ?|||

Sorry, my max_queue_readers where 5 in both situations.

Tim

|||

With one message per conversation then new instances of the stored procedure may be launched, so a message that arrived later may be processed sooner by a new instance activated procedure.

Also, even locally, the message order is only guaranteed within a conversation, so 5 messages sent on 5 conversation may arrive on the target queue in any order (unlikely to arive in different order, but one should not assume order between conversations)

|||You reference that new instances of a sproc may be launched for one message per convo, but what determines if it will or not? Will it only happen if some threshold is exceeded on the queue? The reason I was doing the little test was because I haven't seen any articles out there really detailing good ways to run large processing queries asynchronously for one application, so I was wanting to write one. My main curiosity was if there was any way to modify any of the settings for the procedure activation (which I don't think that there is).|||I just read your blog entry on Parallel Activation...neat stuff. Although, I doubt that it is something I would ever need to implement. I changed my procedures a bit so that they delay for a longer time period, and it appears that a new activation occurs ~ 5 seconds.

Tuesday, March 6, 2012

Acitvation Failure

Setting up database mail of SQL Server 2005 and get an Activation Failure from the database log. Any ideas?

Date 7/11/2007 1:26:03 PM
Log Database Mail (Database Mail Log)

Log ID 2
Last Modified 7/11/2007 1:26:03 PM
Last Modified By sa

Message
Activation failure.

There should be additional information in the event log or SQL Server log.

Jens K. Suessmeyer.

http://www.sqlserver2005.de