2

嗨,有人可以帮我吗?

 declare  @account_name varchar(128) = 'Test Mail Account'
 declare   @description varchar(128)  = 'Mail account for administrative e-mail.'
  declare   @email_address varchar(128) = 'abc@xyz.com'
  declare   @replyto_address varchar(128) = 'abc@xyz.com'
  declare   @display_name varchar(128) = 'Manoj Pandey'
   declare  @mailserver_name varchar(128) = 'smtp.xxxx.net'
 declare    @port int = 587
declare     @username nvarchar(128)= 'xyz'
declare     @password varchar(128) = 'xxyyzz'
declare     @enable_ssl int = 1



    EXECUTE [msdb].[dbo].[sysmail_add_account_sp]
            @account_name,
            @description,
            @email_address,
            @replyto_address,
            @display_name,
            @mailserver_name,
            @port,
            @username,
            @password,
            @enable_ssl

给我一个错误信息:

“消息 8114,级别 16,状态 1,过程 sysmail_add_account_sp,第 0 行错误将数据类型 nvarchar 转换为 int。”

我不知道为什么?

来源来自http://sqlwithmanoj.wordpress.com/2010/09/29/database-mail-setup-sql-server-2005/

谢谢

4

2 回答 2

3

我建议的第一件事是使用命名参数,这样存储的过程就可以准确地知道哪个参数在哪里:

   EXECUTE [msdb].[dbo].[sysmail_add_account_sp]
        @account_name=@account_name,
        @description=@description,
        .....

而且根据 MSDN,您传递它们的顺序看起来不正确 http://technet.microsoft.com/en-us/library/ms182804(v=sql.90).aspx

于 2012-11-16T15:24:18.387 回答
0

如果您不使用命名参数(如 Farfarak 上面所写),那么您不能跳过任何参数(尽管您不需要使用所有参数)。顺序如下:见http://technet.microsoft.com/en-us/library/ms182804.aspx

sysmail_add_account_sp  [ @account_name = ] 'account_name',
    [ @email_address = ] 'email_address' ,
    [ [ @display_name = ] 'display_name' , ]
    [ [ @replyto_address = ] 'replyto_address' , ]
    [ [ @description = ] 'description' , ]
    [ @mailserver_name = ] 'server_name' 
    [ , [ @mailserver_type = ] 'server_type' ]
    [ , [ @port = ] port_number ]
    [ , [ @username = ] 'username' ]
    [ , [ @password = ] 'password' ]
    [ , [ @use_default_credentials = ] use_default_credentials ]
    [ , [ @enable_ssl = ] enable_ssl ]
    [ , [ @account_id = ] account_id OUTPUT ]

此外,声明 enable_ssl 的行应如下所示:

declare     @enable_ssl bit = 1
于 2013-02-17T17:18:19.950 回答