SSIS: Integration services: Throw error from Script Task (Error Handling)

There may be requirement to throw error from Script Task.
Here’s a way to Throw error from Script Task.
//Code Starts Here
Try
‘method which throws an error
Catch e
Me.ComponentMetadata.FireError(-1, “”, “Your Error Message: ” + e.Message, “”, true)
While Not e.InnerException Is Nothing
[...]

SSIS: Logging from script task

This post will show you how to log from the script task.
While logging from inbuilt log system this method helps you to log the exact details of the event in the script task.
using System;
using System.Data;
using System.Math;
using Microsoft.SqlServer.Dts.Runtime;
public class ScriptMain
{
public void Main()
{
[...]

SSIS: Send SMTP mail from Script task

Here i will show how to send SMTP email from a script task rather than the SMTP Mail Task.
Imports System
Imports Microsoft.SqlServer.Dts.Runtime
Imports System.Net.Mail
Imports System.Net
Public Class ScriptMain
Public Sub Main()
Dim myHtmlMessage As MailMessage
Dim mySmtpClient As SmtpClient
myHtmlMessage=New MailMessage(name@helpindotnet.blogspot.com,
[...]

Remove Special Character from XML string using SQL Server

Create a function in MSSQL to remove all special characters from XML.
ALTER FUNCTION [dbo].[RemoveSpChar]
(
– Add the parameters for the function here
@sInput varchar(MAX)=”
)
RETURNS varchar(MAX)
AS
BEGIN
– Declare the return variable here
DECLARE @sOutput Varchar(MAX),
@iIndex int,
@iLength int,
@sChar varchar(1),
@iASCII int,
@iLen int,
@iRem int
set @sInput= ltrim(rtrim(@sInput))
set @iLength = len(@sInput)
set @iIndex =1
set @sOutput=”
while @iIndex <= @iLength
begin
set @sChar=substring(@sInput,@iIndex,1)
set @iASCII=ascii(@sChar)
if ((@iASCII>=48 and @iASCII<=57) or (@iASCII>=65 [...]