Hi
I have created a stored procedure that appeared to run ok. If it was true it send an email in good format with the right information. However, today it sent the email with the subject but no details.
I checked the view out and noticed the address1 field was null but information in the other fields. My hunch is because this files was NUll it did not bring the rest of the information through. Therefore in the scrip how of I allow for potential NUll values. Some of the script is enclosed where I set the variables and fetch statement it up. Any ideas please.
I have created a stored procedure that appeared to run ok. If it was true it send an email in good format with the right information. However, today it sent the email with the subject but no details.
I checked the view out and noticed the address1 field was null but information in the other fields. My hunch is because this files was NUll it did not bring the rest of the information through. Therefore in the scrip how of I allow for potential NUll values. Some of the script is enclosed where I set the variables and fetch statement it up. Any ideas please.
SQL:
DECLARE @message varchar(max)
DECLARE @Recipient1 varchar(max)
DECLARE @Subject1 varchar(max)
DECLARE @OrderNumber varchar (max)
DECLARE @JourneyNumber varchar (max)
DECLARE @OrderStatus varchar (max)
DECLARE @Name varchar (max)
DECLARE @Address1 varchar (max)
DECLARE @City varchar (max)
DECLARE @County varchar (max)
DECLARE @PostCode varchar (max)
DECLARE @ProductCode varchar (max)
DECLARE @Description varchar (max)
DECLARE MY_Cursor Cursor
FOR
SELECT * FROM [servername].[dbo].[viewname] WITH (NOLOCK)
Open My_Cursor
FETCH NEXT FROM MY_Cursor INTO @OrderNumber, @JourneyNumber,
@OrderStatus, @Name, @Address1, @City, @County, @PostCode,
@ProductCode, @Description
WHILE (@@FETCH_STATUS = 0)
BEGIN
SET @message = 'Journey with Waiting for Stock Status '
+ CHAR(13) + CHAR(10) +
'---------------------------------' + CHAR(13)
+ CHAR(10) +
'OrderNumber: ' + @OrderNumber + CHAR(13) +
CHAR(10) +
'JourneyNumber: ' + @JourneyNumber + CHAR(13)
+ CHAR(10) +
'OrderStatus: ' + @OrderStatus + CHAR(13) +
CHAR(10) +
'Name: ' + @Name + CHAR(13) + CHAR(10) +
'Address1: ' + @Address1 + CHAR(13) + CHAR(10)
+
'City: ' + @City + CHAR(13) + CHAR(10) +
'County: ' + @County + CHAR(13) + CHAR(10) +
'PostCode: ' + @PostCode + CHAR(13) + CHAR(10)
+
'ProductCode: ' + @ProductCode + CHAR(13) +
CHAR(10) +
'Description: ' + @Description + CHAR(13) +
CHAR(10)