Friday, 23 August 2013

Run SQL Syntax in EXECUTE msdb.dbo.sp_send_dbmail using dynamic variables.



Declare @Recipient_List nvarchar(max)
Declare @body_Content nvarchar(max)
Declare @Subject nvarchar(max)
Declare @xml nvarchar(max)

set @Recipient_List = 'Yourmail_id@000.com'

set @xml = cast((select count(*) as 'td'

fromdbo.Table_duplicates for XML path('tr'),elements) as nvarchar(max))

set @body_Content = '<html><body><h3> Duplicate Records Found. Verify the table Duplicates to check the duplicate records</h3>

<table border = 1>

<tr>

<th> Total Nunber of Duplicate records </th></tr>'
set

  @body_Content =  @body_Content + @xml + '</table></body></html>'


EXECUTE msdb.dbo.sp_send_dbmail

  @recipients = @Recipient_List,

@subject = 'Count for Duplicate records',

@body = @body_Content,

@body_format = 'HTML'

Monday, 19 August 2013

Move corrupted Flat files into the Error Path using SSIS

One of my interview question in SSIS:

I have nightly SSIS packages are running every day. And this package is schduled to load the 10 flat files into  OLEDB database in every 10 minutes. Now i got one wrong or corrupted Flat file.

The Question is:

Configure a DTSX package if there is any Corrupted file came with missing columns or Delimeters the it should move into the Error Path Location.

How to move Bad or Corrupted flat files or excel files in to the error path?

Answer:

Makesure  Maximum Error count is more than zero.

Basically Maximum Error Count will avoid maximun number of errors.


 
 
Variable: Create a Variable inorder to MAP the For Each Loop Container and Excel Connection manager(Souce)

 
 
Let me share more thought on this senarios.
 
Thank you
Vidya Sagar Malla