我的SSIS工作失败,因为客户名称Cedeñor在其中有波浪号(〜)。错误如下。当我查看这个客户时,我发现客户的姓氏中有一个代字号(~
)。我在没有Tilde的情况下更新了客户姓氏,然后成功运行了作业。
我的问题是如何更改我的存储过程以便从客户名称中删除波浪号(~
),以便将来SSIS作业不会失败。
消息
以用户身份执行:NSI \ EAPSQLAGENT_SUBPROD。从...返回 PopulateEmailSendQueue 0从GetSendEmailRequests 384232390返回 1033937DECLARE @ApplicationID INT,@ ErrCode INT,@ ErrDesc VARCHAR(8000); EXEC dbo.usp_GetCustomerApprovalEmail @ApplicationID = 1033937,@ ErrCode = @ ErrCode OUTPUT,@ ErrDesc = @ ErrDesc OUTPUT结果是 1错误:远程服务器返回错误:(500)内部服务器 错误。处理退出代码1.步骤失败。
ALTER PROC [dbo].[usp_GetCustomerApprovalEmail]
(
@ApplicationID INT
, @ErrCode INT OUTPUT
, @ErrDesc VARCHAR(8000) OUTPUT
)
AS
BEGIN
BEGIN TRY
DECLARE @LanguageID INT
DECLARE @EmailBody VARCHAR(2000)
DECLARE @FirstName VARCHAR(50)
DECLARE @LastName VARCHAR(50)
DECLARE @PhoneNumber VARCHAR(50)
DECLARE @BarCode VARCHAR(50)
DECLARE @MailingAddress VARCHAR(50)
DECLARE @MailingAddressAptNo VARCHAR(50)
DECLARE @MailingAddressCity VARCHAR(50)
DECLARE @MailingAddressState VARCHAR(50)
DECLARE @MailingAddressZip VARCHAR(50)
DECLARE @FromAddress VARCHAR(200)
DECLARE @Subject VARCHAR(100)
DECLARE @CustomerEmail VARCHAR(100)
-- Prep the Email for this customer
SELECT @LanguageID = C.LanguageID
, @FirstName = UPPER(C.FirstName)
, @LastName = UPPER(C.LastName)
, @PhoneNumber = CASE
WHEN C.MobilePhoneNumber IS NOT NULL THEN C.MobilePhoneNumber
WHEN C.LandlinePhoneNumber IS NOT NULL THEN C.LandlinePhoneNumber
ELSE ''
END
, @BarCode = A.BarCodeID
, @MailingAddress = UPPER(C.MailingAddress)
, @MailingAddressAptNo = UPPER(ISNULL(C.MailingAddressAptNo, ''))
, @MailingAddressCity = UPPER(C.MailingAddressCity)
, @MailingAddressState = UPPER(C.MailingAddressState)
, @MailingAddressZip = C.MailingAddressZip
, @CustomerEmail = C.EmailAddress
FROM Customers C (NOLOCK)
INNER JOIN Applications A (NOLOCK) ON A.CustomerID = C.CustomerID
WHERE A.ApplicationID = @ApplicationID
-- Get the approval email template for the appropriate language
SELECT @EmailBody = EmailText
, @FromAddress = FromEmailAddress
, @Subject = [Subject]
FROM EmailTemplate (NOLOCK)
WHERE EmailTemplateID = CASE
WHEN @LanguageID = 1 THEN 3 -- English Approval letter
WHEN @LanguageID = 2 THEN 4 -- English Approval letter
ELSE NULL
END
-- Replace placeholders with data values
SET @EmailBody = REPLACE(@EmailBody, '~PhoneNumber~', @PhoneNumber)
SET @EmailBody = REPLACE(@EmailBody, '~ApplicationID~', @BarCode)
SET @EmailBody = REPLACE(@EmailBody, '~FirstName~', @FirstName)
SET @EmailBody = REPLACE(@EmailBody, '~LastName~', @LastName)
SET @EmailBody = REPLACE(@EmailBody, '~MailingAddress1~', @MailingAddress)
SET @EmailBody = REPLACE(@EmailBody, '~MailingApt~', @MailingAddressAptNo)
SET @EmailBody = REPLACE(@EmailBody, '~MailingCity~', @MailingAddressCity)
SET @EmailBody = REPLACE(@EmailBody, '~MailingState~', @MailingAddressState)
SET @EmailBody = REPLACE(@EmailBody, '~MailingZip~', @MailingAddressZip)
SET @EmailBody = REPLACE(@EmailBody, '~CurrentYear~', CAST(YEAR(GETDATE()) AS VARCHAR(4)))
-- Set date to the proper date
IF (@LanguageID = 1)
SET @EmailBody = REPLACE(@EmailBody, '~DATE~', CONVERT(VARCHAR(10), GETDATE(), 101))
ELSE
SET @EmailBody = REPLACE(@EmailBody, '~DATE~', CONVERT(VARCHAR(10), GETDATE(), 103))
-- Return the data needed to send the email.
SELECT @EmailBody AS EmailBody
, @Subject AS EmailSubject
, @FromAddress AS EmailFromAddress
, @CustomerEmail AS CustomerEmailAddress
END TRY
BEGIN CATCH
Declare @ErrorNumber int,
@ErrorSeverity int,
@ErrorState int,
@ErrorProcedure varchar(8000),
@ErrorLine int,
@ErrorMessage varchar(8000)
Select
@ErrorNumber = Error_Number(),
@ErrorSeverity = Error_Severity(),
@ErrorState = Error_State(),
@ErrorProcedure = Error_Procedure(),
@ErrorLine = Error_Line(),
@ErrorMessage = Error_Message()
Set @ErrCode = @ErrorNumber
Set @ErrDesc = 'Error in usp_GetCustomerApprovalEmail: ' + @ErrorMessage
Execute dbo.[usp_EmailErrorGenerate_Gen]
@ErrorNumber,
@ErrorSeverity,
@ErrorState,
@ErrorProcedure,
@ErrorLine,
@ErrorMessage
END CATCH
END
答案 0 :(得分:0)
在'之后添加此内容 - 返回发送电子邮件所需的数据':
SET @EmailBody = Replace( @EmailBody COLLATE Latin1_General_CS_AI, 'a', 'a' );
SET @EmailBody = Replace( @EmailBody COLLATE Latin1_General_CS_AI, 'e', 'e' );
SET @EmailBody = Replace( @EmailBody COLLATE Latin1_General_CS_AI, 'i', 'i' );
SET @EmailBody = Replace( @EmailBody COLLATE Latin1_General_CS_AI, 'o', 'o' );
SET @EmailBody = Replace( @EmailBody COLLATE Latin1_General_CS_AI, 'u', 'u' );
SET @EmailBody = Replace( @EmailBody COLLATE Latin1_General_CS_AI, 'y', 'y' );
SET @EmailBody = Replace( @EmailBody COLLATE Latin1_General_CS_AI, 'n', 'n' );
SET @EmailBody = Replace( @EmailBody COLLATE Latin1_General_CS_AI, 'œ', 'oe' );
SET @EmailBody = Replace( @EmailBody COLLATE Latin1_General_CS_AI, 'æ', 'ae' );
SET @EmailBody = Replace( @EmailBody COLLATE Latin1_General_CS_AI, 'ß', 'ss' );
SET @EmailBody = Replace( @EmailBody COLLATE Latin1_General_CS_AI, 's', 's' );
SET @EmailBody = Replace( @EmailBody COLLATE Latin1_General_CS_AI, 'A', 'A' );
SET @EmailBody = Replace( @EmailBody COLLATE Latin1_General_CS_AI, 'E', 'E' );
SET @EmailBody = Replace( @EmailBody COLLATE Latin1_General_CS_AI, 'I', 'I' );
SET @EmailBody = Replace( @EmailBody COLLATE Latin1_General_CS_AI, 'O', 'O' );
SET @EmailBody = Replace( @EmailBody COLLATE Latin1_General_CS_AI, 'U', 'U' );
SET @EmailBody = Replace( @EmailBody COLLATE Latin1_General_CS_AI, 'Y', 'Y' );
SET @EmailBody = Replace( @EmailBody COLLATE Latin1_General_CS_AI, 'N', 'N' );
SET @EmailBody = Replace( @EmailBody COLLATE Latin1_General_CS_AI, 'Œ', 'OE' );
SET @EmailBody = Replace( @EmailBody COLLATE Latin1_General_CS_AI, 'Æ', 'AE' );
SET @EmailBody = Replace( @EmailBody COLLATE Latin1_General_CS_AI, 'ß', 'SS' );
SET @EmailBody = Replace( @EmailBody COLLATE Latin1_General_CS_AI, 'S', 'S' );