有人可以帮我这个吗?
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/
由于
答案 0 :(得分: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
答案 1 :(得分: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