Jump to content

Ssis Experts Need Help


Recommended Posts

Posted

Flat file destination : header lo line break kavali how ? nenu expression use chestunna (\n) , evaluate avutundi kani file lo line break ravatledu

Posted

CHAR(13) try chesaava instead of \n.. that also acts as a line break..

Posted

flat file header lo line breaks kavali

Example : Red mottam header adi multiple lines lo ravali ,a tarvatha column names with pipe symbol
[b][color=#ff0000]&CID=936[/color][/b]
[b][color=#ff0000]&SUBID=123[/color][/b]
[b][color=#ff0000]&PROCESSTYPE=OVERWRITE[/color][/b]
[b][color=#ff0000]&AID=1643253[/color][/b]
[b][color=#ff0000]&PARAMETERS=[/color][/b]
NAME|KEYWORDS|DESCRIPTION|SKU|BUYURL|AVAILABLE

Posted

hmm script tak use chestaanantey cheppu oka script undi monnaney sraasaamu header ki adi istaa

Posted

yes, deeniki script task ye correct... naaku kuda pampi adey chetto darling..

Posted

[quote name='DARLING...' timestamp='1377272006' post='1304154200']
hmm script tak use chestaanantey cheppu oka script undi monnaney sraasaamu header ki adi istaa
[/quote]

yup , pampu bro try chestha

Posted

[CODE]
/*
Microsoft SQL Server Integration Services Script Task
Write scripts using Microsoft Visual C# 2008.
The ScriptMain is the entry point class of the script.
*/
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using System.IO;
using System.Globalization;
namespace ST_98f75d104a1041acbaa1c9050306cde9.csproj
{
[System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
#region VSTA generated code
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
};
#endregion
/*
The execution engine calls this method when the task executes.
To access the object model, use the Dts property. Connections, variables, events,
and logging features are available as members of the Dts property as shown in the following examples.
To reference a variable, call Dts.Variables["MyCaseSensitiveVariableName"].Value;
To post a log entry, call Dts.Log("This is my log text", 999, null);
To fire an event, call Dts.Events.FireInformation(99, "test", "hit the help message", "", 0, true);
To use the connections collection use something like the following:
ConnectionManager cm = Dts.Connections.Add("OLEDB");
cm.ConnectionString = "Data Source=localhost;Initial Catalog=AdventureWorks;Provider=SQLNCLI10;Integrated Security=SSPI;Auto Translate=False;";
Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.

To open Help, press F1.
*/
public void Main()
{
try
{
// Determine Filenames using the Flat File Connection manager
string FileName = Dts.Connections["FILE_NAME"].ConnectionString;
string tempFileName = FileName + ".temp";
string reqfilename = Dts.Variables["FileNamePrefix"].Value.ToString();
reqfilename = reqfilename + DateTime.Now.ToString("yyyyMMddHHMMss") + ".txt";
string[] s = FileName.Split('\\');
string stemp = "";
for (int i = 0; i < (s.Length - 1); i++)
stemp = stemp + s[i] + @"\";
reqfilename = stemp + reqfilename;
//string Mail_path = Dts.Variables["User::Mail_path"].ToString();
//Mail_path = reqfilename;
if (File.Exists(tempFileName))
File.Delete(tempFileName);
// Create temporary copy of source file
File.Move(FileName, tempFileName);
StreamReader tempinput = new StreamReader(tempFileName);
int iLineCount = 0;
string firstline = "";
string templine = "";
while ((templine = tempinput.ReadLine()) != null)
{
if (templine != "")
{
firstline = templine;
iLineCount++;
}
}
tempinput.Close();
string dataThru = DateTime.Parse(firstline.Split('|')[3]).ToString("MM/dd/yyyy");

using (StreamReader input = new StreamReader(tempFileName))
{
using (StreamWriter output = new StreamWriter(FileName, false))
{
// Create header in empty file
string[] formats = { "MM/dd/yyyy" };
var dtCurrentDate = DateTime.Now.ToString("MM/dd/yyyy");
//DateTime.ParseExact(DateTime.Today.ToShortDateString(), formats, new CultureInfo("en-US"), DateTimeStyles.None);
output.WriteLine(Dts.Variables["HeaderPrefix"].Value.ToString() + dataThru + dtCurrentDate);
//Dts.Variables["DataThru"].Value.ToString()
// Create a buffer. This is needed for large files that won't fit in the servers RAM
var buf = new char[4096];
// Read temporary copy of source file in blocks
// and write in blocks to empty file with header
int read = 0;
do
{
read = input.ReadBlock(buf, 0, buf.Length);
output.Write(buf, 0, read);
} while (read > 0);
string sFooter = "";
int iFooterPlaceholderLen = Dts.Variables["FooterPlaceHolder"].Value.ToString().Length;
//iFooterPlaceholderLen = iFooterPlaceholderLen;// -Dts.Variables["RowCount"].Value.ToString().Length;
sFooter = (iLineCount.ToString()).PadLeft(iFooterPlaceholderLen, '0');
sFooter = "99TRL" + sFooter;
output.WriteLine(sFooter);
// Clear and close
output.Flush();
output.Close();
input.Close();
}
}
// temporary copy of source file
File.Delete(tempFileName);
File.Move(FileName, reqfilename);
Dts.Variables["User::Mail_Path"].Value = reqfilename;
// Close Script Task with Succes
Dts.TaskResult = (int)ScriptResults.Success;
}
catch (Exception ex)
{
// Log error
Dts.Events.FireError(0, "Write header", ex.Message, string.Empty, 0);
// Close Script Task with Failure
Dts.TaskResult = (int)ScriptResults.Failure;
}
}
}
}
[/CODE]

indulo unna parameters anni bayata string ichi create cheyyi package level lo and assign them to script task read/write variables.

×
×
  • Create New...