Skip to main content

Posts

Showing posts from December, 2009

Email Alerts are not received...

In one of application, Email alerts are sent using SQL sp_send_dbmail stored procedure. Email alerts were working properly, but suddenly noticed email alerts are not received.

To troubleshoot the issue, first I checked the msdb.dbo.sysmail_event_log table using the below query.

SELECT log_id, event_type, log_date, description, process_id, mailitem_id, account_id, last_mod_date, last_mod_user
FROM
msdb.dbo.sysmail_event_log 
ORDER BY
log_date DESC

If there is any error, you should see records with the event_type value as error.
In my case there are records with event_type value as error, and the description value for those records is same as below

The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 3 (2018-02-01T10:41:27). Exception Message: Cannot send mails to mail server. (The SMTP server requires a secure connection or the client was not authenticated. The server response was: Authentication required).  )

As per the error descript…

MS SQL Function to Convert the Julian Date to the SQL Date Format

Below I put the query for a SQL Function which converts the Julian
date in int data type to SQL Date format.
IF EXISTS (SELECT * FROM sys.objects WHERE object_id =
OBJECT_ID(N'dbo.Convert_Julian') AND TYPE IN (N'FN', N'IF', N'TF',
N'FS', N'FT'))DROP FUNCTION dbo.Convert_Julian GOCREATE FUNCTION dbo.Convert_Julian(@idate INT)
Returns DATE
WITH EXECUTE AS CALLER ASBEGIN
DECLARE @oDate DATE, @year VARCHAR(10),@intYear INT,@sdate
VARCHAR(10),@noOfDays VARCHAR(10),@intNoOfDays INT,@month INT,@day
INT,@sMonth VARCHAR(10),@sDay VARCHAR(10),@sMonthc VARCHAR(10),@sDayc
VARCHAR(10)SELECT @sdate=CONVERT(VARCHAR(50),@idate) IF (@idate=0) SET @oDate = CAST(0 AS DATETIME) ELSE BEGIN
SET @year=SUBSTRING(@sdate,1,4)
SET @noOfDays=SUBSTRING(@sdate,5,3)
SELECT @intYear=CONVERT(INT,@year)
SELECT @intNoOfDays=CONVERT(INT,@noOfDays)

IF (@intNoOfDays<=31)
BEGIN
SELECT @month=1

IF(@intNoOfDays=31)
SELECT @day=31

ELSE
SELECT @day=@intNoOfDays
END

IF(@intNoOfD…

Creating a Connection to DB2 in SQL Server Integration Project

In this post, IBM DB2 UDB for iSeries IBMDA400 OLE DB provider is used to create the connection.
To create a connection in SQL Server Integration Project, Right click on the Connection Managers area and select New OLE DB Connection... as shown in the below figure.



Then select the Provider in the top of Connection Manager as the Native OLE DB\ IBM DB2 UDB for iSeries IBMDA400 OLE DB Provider as shown in the below figure.



Then Click on the Data Links... button to provide more details and you will get a screen like a below one.



Then provide the Server Name or IP Address of the Server for the Data Source and provide the required credentials.
After that to provide the required DB2 library click on the All tab and double click on Catalog Library List.
Then you will get a screen as shown below.



Enter the DB2 Library for the Property Value and click OK.

Then you can test the created connection by clicking Test Connection button and if you provided those details correctly you will get a message as sho…