Quantcast
Channel: SQL Server Integration Services forum
Viewing all 24688 articles
Browse latest View live

Error while using Sequence container in SSIS 2012

$
0
0

Hi,

I have an SSIS package which is using Sequence container. Till yesterday everything was working fine, but all of a sudden today i started getting following error:

 The SSIS Runtime has failed to commit the distributed transaction due to error 0x8004D019 "The transaction has already been aborted.’

Please suggest some solution.

Thanks in advance.


No fuzzy complement appears in user without administrator rights

$
0
0
Instsalefuzzyon a pcthat is ina domainas administratorI get the supplement, butwhen I gotorestricted user(without administrator rights)does not appearfuzzycomplement.

They couldhelpmeurgent thanks

Atte

PatrickBerger

Metadata errors – OLE DB Source/Destination Components

$
0
0

I’m trying to perform dynamic processing of data to update destination tables with new and changed data. I’m pulling that data from a number of tables in one server to the other (from SQL 2005 to SQL 2008). The good thing is that table names and column names are exactly the same between the source and destination databases. I have already created all the necessary variables and expressions in SSIS to perform these dynamic tasks. My predicament now lies on metadata errors resulting from OLE DB Source and Destination components. May I know if there is a way to make the OLE DB Source and Destination components to dynamically adapt/update metadata definitions in line with the table names/definitions which will be constantly changing in the input variable? I have changed the ValidateExternalMetadata property to False, and I have also changed DelayValidation property to True but still I’m getting metadata errors.

I hope my question is clear.

Many thanks,


Mpumelelo

FTP Task disable logging on folder creation

$
0
0

I have an FTP task that is set up to create a folder.  If the folder exists when the task runs, the task throws an error like this,

[Connection manager "FTP Connection Manager"] Error: Creating folder "/Test" ... 550 Directory already exists.

while I understand this the desired default behavior I would like to disable it.  I'm using SSISDB catalog to feed a watchdog client and this error gives me false positives.  In addition, after some searching, it appears the go-to solution is to use a Script Task however I have many legacy jobs that I'd like to minimize changes for.

Thank you for any and all help


Getting a BACPAC

$
0
0

Hi

One of our clients has started using Azure for their website and would like a monthly BACPAC export from our in house CRM system.

We are using SQL 2008R2, I notice from this MSDN article that we can get a BACPAC out of SQL 2008R2 by installing SQL Server Data Tools.  We don't have a full version of Visual Studio so from what I understand the shell will be installed

I am wary of installing anything on my production SQL server and was wondering if it is necessary to install this directly on an SQL Server, or can it be installed on another server/workstation and the process create from there?

Many thanks

MS BI overview question

$
0
0

Hello,

We have a microsoft BI solution that has 4 databases, 2 SSAS databases, 200+ SSIS packages and 100+ SSRS reports. The databases have over 800 tables. The users are very happy but our BI solution has grown bigger and we are now facing the point that it is becoming too complex. The problem is, suppose we change this field in the staging database, which other changes should we make ? Make those fields in that other database bigger. Change the reports X,Y,Z. Update the SSIS packages ? Other problem that field/value  in SSAS where is it coming from ? If you make an SSIS package, do you make it source driven (source table 1 is filling target tables 1 and 2 and 5) or targer driven (target table 1 is being filled by source tables 1, 4,5) ?

We are currently as SQL 2008 R8. Will SQL 2012 solve these problems ?

Any suggestions ?

Constantijn

inserting variable into object variable conditionally in for each loop

$
0
0

Hi

I want to use the variable value   from for each loop    and insert into object variable .In the for each loop i have few tasks and want to insert the variable  values  into object variable conditionally after the success of those  tasks which are  depended on the variables from the for each loop.So my object variable should contain only the variables which are successful on the tasks

Many Thanks

 

IF condition not working in sql execute task SSIS

$
0
0

IF condition not working in sql execute task SSIS

getting error :

The query failed to parse. Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.

I'm checking for the table is there or not which i have created in excel destination.

How do I tackle this ?

IF OBJECT_ID(N'MyExcel')ISNOTNULLBEGINDROPTABLE MyExcel;END;


Ashish Fugat (ashuthinksatgmail.com) SE




Temp Tables and no Output Columns

$
0
0

I no that there's a trick to "fool" SSIS using the

IF 1=2
Select
 CAST(0 as int) as [Store No]
 ,CAST('' as varchar(10)) as MaxRptDate
 ,CAST('' as varchar(10)) as MinRptDate
 ,CAST('' as varchar(15)) as [UPC]
 ,CAST(0 as int) as [Quantity Sold]
 ,CAST('' as varchar(50))[Friendly Desc]
 ,CAST(0 as int) as [Vendor Item Number]

Well it's happened again where I have pointed the OLE DB to a stored procedure and someone changed the SP from table variables to temp tables and though the output columns are exactly alike - it broke the mappings and the SSIS package failed.

My questions:

1. Is there not a way to maually edit a settings file within the SSIS project to map the output to the flat file.  The output from a temp table SP and the table variable SP is exactly the same so why can't we tell the SSIS this and it always works?

2. The whole idea of the stored procedure was the idea that it would be easier to modify without having to change the dtsx package.  As long as the output columns were the same it should work but of course this isn't the case. Ideas?  or is there just a rule of thumb that temp tables and SSIS are not compatible?

Login timeout expired

$
0
0

Hi,

we have a set of ssis packages which were running fine before.

But now they are throwing errors----Login timeout expired.

Please let me know what could be the reason for this type of error.

Thank you

Gopichand

PK violation capture

$
0
0

hi all,

I am trying to load a table from some flat files.

Is it possible to redirect only those rows that violate the PK constraint to a badData file and keep the good records going into my table?

I tried implementing a Data Flow Task that has a FF source, a Data Conversion step and a SQL Server (OLE DB) Destination with a flat file on the error output of the data conversion block, however, the process as seen in the Output, it loads all records, then catches the PK violation and cleans up everything - hence mnothing in my table, nothing in the badData file ...

thanks,
kowalsky

Cannot insert duplicate key row in object ERROR

$
0
0

Dear ALL,

I have a simple data flow task in my package. What i'm doing is merging data from two different sources. The destination table has a field 'AgeOfActiveDetailID' which is the primary key and it is not from the source (i have no idea how its getting populated). What my package is supposed to do is add the data from the second source to this DESTINATION TABLE. When i execute the job i get the following error:

An OLE DB record is available.  Source: "Microsoft SQL Server Native Client 10.0" Hresult: 0x80004005  Description: "Cannot insert duplicate key row in object 'dbo.AgeOfActiveDetail' with unique index 'idx_AgeOfActiveDetail'. The duplicate key value is (Jan 24 1901 12:00AM, 49, 1, 13417500, <NULL>).".

Please need help


SV

ssis package adding header and footer

$
0
0

HI I HAVE SCRIPT WHICH GIVES ME FOLLOWING RESULT. i have to add header and trailer in data using c#. i wrote code which gives this result which is not what i want. 

CHD

SEQUENCE ID

RECORD TYPE

AMOUNT

000034006

00000678

$5869

CHD

SEQUENCE ID

RECORD TYPE

AMOUNT

0006780000

384900000

$856840

CHD

SEQUENCE ID

RECORD TYPE

AMOUNT

8930000

834444

$78098

the desire result i want is following. 

CHD

SEQUENCE ID

RECORD TYPE

AMOUNT

000034006

00000678

$5869

0006780000

384900000

$856840

8930000

834444

$78098

how am i suppose to get this result either by using flat file or C#. I have script, should i add it in script or use another script. 

Guide me. 

/*
   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.IO;
using System.Text;
using System.Data;
//using System.Math;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
namespace ST_8b99b23ffd944c6abe15bca3437320d8.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
        public void Main()
        {
            Dts.TaskResult = (int)ScriptResults.Success;
            Boolean fireagain = false;
            int taskResult;
            string fileSourcePath;
            string fileDestPath;
            StreamReader sr;
            StreamWriter sw;
            string Str;
            string delim = ",";
            string RecordType;
            //         Dim FileCreateDate As Date
            string LastRecordType = "   ";
            string FilesProcessed;
            string CurrentDate;
            string SourceFilePath;
            string FileName;
            // Dim ret As Integer
            CurrentDate = DateTime.Now.ToString("yyyyMMdd");
            Dts.Events.FireInformation(-1, "CurrentDate", CurrentDate.ToString(), String.Empty, 0, ref fireagain);
            try
            {
                fileSourcePath= Dts.Variables["User::SourceFilePath"].Value.ToString(); //SourceFilePath
                fileDestPath = Dts.Variables["User::Destination"].Value.ToString();//Destination
                FilesProcessed = Dts.Variables["User::FilesProcessed"].Value.ToString();//FilesProcessed
                FileName = Dts.Variables["User::FileName"].Value.ToString();
                //fileSourcePath = Dts.Variables["SourceFilePath"].Value.ToString();//FilePath 
                //fileDestPath = Dts.Variable["Destination"].Value.ToString;//Destination
                //FilesProcessed = ReadVariable("FilesProcessed").ToString();//FilesProcessed
                //FileName = Dts.Variables["FileName"].Value.ToString();//FileName
                //the value before we change it here
                Dts.Events.FireInformation(1, "fileSourcePath", fileSourcePath, String.Empty, 0, ref fireagain);
                Dts.Events.FireInformation(-1, "FileName", FileName, String.Empty, 0, ref fireagain);
                //  Dim valid As Boolean
                //  Dim fileID As String
                //  Dim contract As Stri
                int sep;
                sep = FileName.IndexOf("//");
                SourceFilePath = FileName.Substring((sep + 1));//fileSourcePath.Substring((sep + 1));
                Dts.Events.FireInformation(-1, "SourceFilePath", SourceFilePath, String.Empty, 0, ref fireagain);
                //sr = File.OpenText(fileSourcePath + FileName);//File.OpenText(fileSourcePath);
                sr = File.OpenText(FileName);
                //string test = Dts.Variables[sr].Value.ToString();
                Str = sr.ReadLine();
                //Dts.Variables[Str].Value.ToString();
                //Dts.Events.FireInformation(-1, "Str-ReadLine", Str.ToString(), String.Empty, 0, ref fireagain);
                // Get the first data line of the file
                //     contract = Str.Substring(10, 5)
                //    fileID = Str.Substring(15, 12)
                Int32 Counter;
                Counter = (int)ReadVariable("Counter");
                Counter = (Counter + 1);
                WriteVariable("Counter", Counter);
                Dts.Events.FireInformation(-1, "Counter", Counter.ToString(), String.Empty, 0, ref fireagain);
                //int loc = fileDestPath.LastIndexOf(".");
                //string ext = fileDestPath.Substring(loc, 4);
                //string filename = fileDestPath.Substring(0, loc);
                //  fileDestPath = filename + "_" + DateTime.Now.ToString("yyyyMMdd") + ext
                fileDestPath = Dts.Variables["User::Destination"].Value.ToString() + "_" + CurrentDate + ".CSV";
                sw = File.CreateText(fileDestPath);
                WriteVariable("NewFileName", fileDestPath);
                Dts.Events.FireInformation(-1, "NewFileName", ReadVariable("NewFileName").ToString(), String.Empty, 0, ref fireagain);
                //cnt = 1;
                while (!string.IsNullOrEmpty(Str))
                {
                    StringBuilder sb = new StringBuilder();
                    if ((Str.Length > 3))
                    {
                        // No Valid records have less than 3 chars
                       RecordType = Str.Substring(0, 3);
                        switch (RecordType)
                        {
                            case "CHD":
                                sw.WriteLine("RECORD ID,SEQUENCE NO,CONTRACT IDENTIFIER,CONTRACT NAME,COVERAGE YEAR DATE,RECONCILIATION NUMBER,SYSTEM DATE,SYSTEM TIME,REPORT ID,FILLER");
                                sb.Append((Str.Substring(0, 3) + delim));
                                // RECORD-ID
                                sb.Append((Str.Substring(3, 7) + delim));
                                // SEQUENCE-NO
                                sb.Append((Str.Substring(10, 5) + delim));
                                // CONTRACT-IDENTIFIER
                                sb.Append((Str.Substring(15, 50) + delim));
                                // CONTRACT-NAME
                                sb.Append((Str.Substring(65, 4) + delim));
                                // COVERAGE-YEAR-DATE
                                sb.Append((Str.Substring(69, 4) + delim));
                                // RECONCILIATION-NUMBER
                                sb.Append((Str.Substring(73, 8) + delim));
                                // SYSTEM-DATE
                                sb.Append((Str.Substring(79, 6) + delim));
                                // SYSTEM-TIME
                                sb.Append((Str.Substring(87, 9) + delim));
                                // REPORT-ID
                                sb.Append((Str.Substring(96, 204) + delim));
                                // FILLER
                                sw.WriteLine(sb.ToString());
                                Dts.Events.FireInformation(-1, "sb", sb.ToString(), String.Empty, 0, ref fireagain);
                                break;
                            case "DET":
                                if (!(LastRecordType == RecordType))
                                {
                                    sw.WriteLine("RECORD ID," +"SEQUENCE NO," +"CONTRACT IDENTIFIER," +"PLAN BENEFIT PACKAGE IDENTIFIER," +"CONTRACT NAME," +"PBP NAME," +"CURRENT RECONCILIATION NUMBER," +"PREVIOUS RECOUNCILIATION NUMBER," +"CURRENT TOTAL COVERAGE GAP DISCOUNT PAYMENT AMOUNT," +"PREVIOUS TOTAL COVERAGE GAP DISCOUNT PAYMENT AMOUNT," +"DELTA TOTAL COVERAGE GAP DISCOUNT PAYMENT AMOUNT," +"CURRENT TOTAL COVERAGE GAP DISCOUNT INVOICED AMOUNT," +"PREVIOUS TOTAL COVERAGE GAP DISCOUNT INVOICED AMOUNT," +"DELTA TOTAL COVERAGE GAP DISCOUNT INVOICED AMOUNT," +"CURRENT COVERAGE GAP DISCOUNT RECONCILIATION AMOUNT," +"PREVIOUS COVERAGE GAP DISCOUNT RECONCILIATION AMOUNT," +"DELTA COVERAGE GAP DISCOUNT RECONCILIATION AMOUNT," +"FILLER"
                                          );
                                }
                                sb.Append((Str.Substring(0, 3) + delim));
                                // RECORD-ID
                                sb.Append((Str.Substring(3, 7) + delim));
                                // SEQUENCE-NO
                                sb.Append((Str.Substring(10, 5) + delim));
                                // CONTRACT-IDENTIFIER
                                sb.Append((Str.Substring(15, 3) + delim));
                                // PLAN-BENEFIT-PACKAGE-IDENTIFIER
                                sb.Append((Str.Substring(18, 50) + delim));
                                // CONTRACT-NAME
                                sb.Append((Str.Substring(68, 50) + delim));
                                // PBP-NAME
                                sb.Append((Str.Substring(118, 4) + delim));
                                // CURRENT RECONCILIATION NUMBER
                                sb.Append((Str.Substring(122, 4) + delim));
                                // PREVIOUS RECONCILIATION NUMBER 
                                sb.Append(("$"+ ConvertEBCDIC(Str.Substring(126, 14)).ToString ("F2") + delim));
                                //CURRENT TOTAL COVERAGE GAP DISCOUNT PAYMENT AMOUNT 
                                sb.Append(("$"+ ConvertEBCDIC(Str.Substring(140, 14)).ToString("F2") + delim));
                                // PREVIOUS TOTAL COVERAGE GAP DISCOUNT PAYMENT AMOUNT
                                sb.Append(("$" + ConvertEBCDIC(Str.Substring(154, 14)).ToString("F2") + delim));
                                // DELTA TOTAL COVERAGE GAP DISCOUNT PAYMENT AMOUNT
                                sb.Append(("$"+ ConvertEBCDIC(Str.Substring(168, 14)).ToString("F2") + delim));
                                // CURRENT TOTAL COVERAGE GAP DISCOUNT INVOICED AMOUNT
                                sb.Append(("$"+ ConvertEBCDIC(Str.Substring(182, 14)).ToString("F2") + delim));
                                // PREVIOUS TOTAL COVERAGE GAP DISCOUNT INVOICED AMOUNT
                                sb.Append(("$"+ ConvertEBCDIC(Str.Substring(196, 14)).ToString("F2") + delim));
                                // DELTA TOTAL COVERAGE GAP DISCOUNT INVOICED AMOUNT 
                                sb.Append(("$"+ ConvertEBCDIC(Str.Substring(210, 14)).ToString("F2") + delim));
                                // CURRENT COVERAGE GAP DISCOUNT RECONCILIATION AMOUNT
                                sb.Append(("$"+ ConvertEBCDIC(Str.Substring(224, 14)).ToString("F2") + delim));
                                // PREVIOUS COVERAGE GAP DISCOUNT RECONCILIATION AMOUNT
                                sb.Append(("$"+ ConvertEBCDIC(Str.Substring(238, 14)).ToString("F2") + delim));
                                // DELTA COVERAGE GAP DISCOUNT RECONCILIATION AMOUNT 
                                sb.Append((Str.Substring(252, 48) + delim));
                                // FILLER
                                sw.WriteLine(sb.ToString());
                                Dts.Events.FireInformation(-1, "sb", sb.ToString(), String.Empty, 0, ref fireagain);
                                break;
                            case "CTR":
                                sw.WriteLine("RECORD ID," +"SEQUENCE NO," +"CONTRACT IDENTIFIER," +"CONTRACT NAME," +"CURRENT RECONCILATION NUMBER," +"CURRENT TOTAL COVERAGE GAP DISCOUNT PAYMENT AMOUNT," +"PREVIOUS TOTAL COVERAGE GAP DISCOUNT PAYMENT AMOUNT," +"DELTA TOTAL COVERAGE GAP DISCOUNT PAYMENT AMOUNT," +"CURRENT TOTAL COVERGAE GAP DISCOUNT INVOICED AMOUNT," +"PREVIOUS TOTAL COVERAGE GAP DISCOUNT INVOICED AMOUNT," +"DELTA TOTAL COVERAGE GAP DISCOUNT INVOICED AMOUNT," +"CURRENT COVERAGE GAP DISCOUNT RECONCILIATION AMOUNT," +"PREVIOUS COVERAGE GAP DISCOUNT RECONCILIATION AMOUNT," +"DELTA COVERAGE GAP DISCOUNT RECONCILIATION AMOUNT," +"COUNT OF PBPs," +"FILLER"
                                );
                                sb.Append((Str.Substring(0, 3) + delim));
                                // RECORD-ID
                                sb.Append((Str.Substring(3, 7) + delim));
                                // SEQUENCE-NO
                                sb.Append((Str.Substring(10, 5) + delim));
                                // CONTRACT-IDENTIFIER
                                sb.Append((Str.Substring(15, 50) + delim));
                                // CONTRACT-NAME  
                                sb.Append((Str.Substring(65, 4) + delim));
                                // CURRENT RECONCILATION NUMBER
                                sb.Append(("$"+ ConvertEBCDIC(Str.Substring(69, 14)).ToString("F2") + delim));
                                // CURRENT TOTAL COVERAGE GAP DISCOUNT PAYMENT AMOUNT 
                                sb.Append(("$"+ ConvertEBCDIC(Str.Substring(83, 14)).ToString("F2") + delim));
                                // PREVIOUS TOTAL COVERAGE GAP DISCOUNT PAYMENT AMOUNT
                                sb.Append(("$"+ ConvertEBCDIC(Str.Substring(97, 14)).ToString("F2") + delim));
                                // DELTA TOTAL COVERAGE GAP DISCOUNT PAYMENT AMOUNT
                                sb.Append(("$"+ ConvertEBCDIC(Str.Substring(111, 14)).ToString("F2") + delim));
                                // CURRENT TOTAL COVERAGE GAP DISCOUNT INVOICED AMOUNT
                                sb.Append(("$"+ ConvertEBCDIC(Str.Substring(125, 14)).ToString("F2") + delim));
                                // PREVIOUS TOTAL COVERAGE GAP DISCOUNT INVOICED AMOUNT
                                sb.Append(("$"+ ConvertEBCDIC(Str.Substring(139, 14)).ToString("F2") + delim));
                                // DELTA TOTAL COVERAGE GAP DISCOUNT INVOICED AMOUNT
                                sb.Append(("$"+ ConvertEBCDIC(Str.Substring(153, 14)).ToString("F2") + delim));
                                // CURRENT COVERAGE GAP DISCOUNT RECONCILIATION AMOUNT
                                sb.Append(("$"+ ConvertEBCDIC(Str.Substring(167, 14)).ToString("F2") + delim));
                                // PREVIOUS COVERAGE GAP DISCOUNT RECONCILIATION AMOUNT
                                sb.Append(("$"+ ConvertEBCDIC(Str.Substring(181, 14)).ToString("F2") + delim));
                                // DELTA COVERAGE GAP DISCOUNT RECONCILIATION AMOUNT 
                                sb.Append((Str.Substring(195, 9) + delim));
                                // COUNT OF PBPs
                                sb.Append((Str.Substring(204, 96) + delim));
                                // FILLER
                                sw.WriteLine(sb.ToString());
                                Dts.Events.FireInformation(-1, "sb Tail", sb.ToString(), String.Empty, 0, ref fireagain);
                                break;
                            default:
                            sw.WriteLine("INVALID");
                            break;
                        }
                    }
                    //LastRecordType = RecordType.ToString();
                    Str = sr.ReadLine();
                }
                sr.Close();
                sw.Close();
                // WriteVariable("FilesProcessed", (FilesProcessed
                //                + (fileDestPath.Replace(ReadVariable("P2PPayableReportPath").ToString(), "").ToString + "\r\n")));
            }
            catch (Exception ex)
            {
                taskResult = Dts.TaskResult = (int)ScriptResults.Failure;
                Dts.Events.FireError(-1, "Exception", ex.Message, String.Empty, 0);
            }
            Dts.TaskResult = (int)ScriptResults.Success;
        }
        Decimal ConvertEBCDIC(string signed)
        {
            string signChar;
            string numb;
            Decimal nn = 0;
            Decimal final = 0;
            int len;
            Boolean fireagain = false;
            bool negative = false;
            Dts.Events.FireInformation(-1, "function input string", signed.ToString(), String.Empty, 0, ref fireagain);
            if ((signed.Length > 1))
            {
                len = signed.Length;
                signChar = signed.Substring((len - 1), 1);
                //  last character only, which includes sign
                numb = signed.Substring(0, (len - 1));
                Dts.Events.FireInformation(-1, "ssignChar", signChar.ToString(), String.Empty, 0, ref fireagain);
                Dts.Events.FireInformation(-1, "numb", numb.ToString(), String.Empty, 0, ref fireagain);
                // number with out the last digit
                switch (signChar)
                {
                    case "{":
                        nn = 0;
                        break;
                    case "A":
                        nn = 1;
                        break;
                    case "B":
                        nn = 2;
                        break;
                    case "C":
                        nn = 3;
                        break;
                    case "D":
                        nn = 4;
                        break;
                    case "E":
                        nn = 5;
                        break;
                    case "F":
                        nn = 6;
                        break;
                    case "G":
                        nn = 7;
                        break;
                    case "H":
                        nn = 8;
                        break;
                    case "I":
                        nn = 9;
                        break;
                    case "}":
                        nn = 0;
                        negative = true;
                        break;
                    case "J":
                        nn = 1;
                        negative = true;
                        break;
                    case "K":
                        nn = 2;
                        negative = true;
                        break;
                    case "L":
                        nn = 2;
                        negative = true;
                        break;
                    case "M":
                        nn = 4;
                        negative = true;
                        break;
                    case "N":
                        nn = 5;
                        negative = true;
                        break;
                    case "O":
                        nn = 6;
                        negative = true;
                        break;
                    case "P":
                        nn = 7;
                        negative = true;
                        break;
                    case "Q":
                        nn = 8;
                        negative = true;
                        break;
                    case "R":
                        nn = 9;
                        negative = true;
                        break;
                }
                final = Decimal.Parse(numb);
                Dts.Events.FireInformation(-1, "final 1", final.ToString(), String.Empty, 0, ref fireagain);
                final = (final * 10);
                Dts.Events.FireInformation(-1, "final 2", final.ToString(), String.Empty, 0, ref fireagain);
                final = (final + nn);
                Dts.Events.FireInformation(-1, "final 3", final.ToString(), String.Empty, 0, ref fireagain);
                final = (final / 100);
                if (negative)
                {
                    final = (final * -1);
                }
                Dts.Events.FireInformation(-1, "final 4", final.ToString(), String.Empty, 0, ref fireagain);
            }
            return final;
        }
        Decimal ConvertEBCDICDivideBy10000(string signed)
        {
            string signChar;
            string numb;
            Decimal nn = 0;
            Decimal final = 0;
            int len;
            Boolean fireagain = false;
            bool negative = false;
            //   Dts.Events.FireInformation(-1, "function input string", signed.ToString(), String.Empty, 0, ref fireagain);
            if ((signed.Length > 1))
            {
                len = signed.Length;
                signChar = signed.Substring((len - 1), 1);
                //  last character only, which includes sign
                numb = signed.Substring(0, (len - 1));
                Dts.Events.FireInformation(-1, "ssignChar", signChar.ToString(), String.Empty, 0, ref fireagain);
                Dts.Events.FireInformation(-1, "numb", numb.ToString(), String.Empty, 0, ref fireagain);
                // number with out the last digit
                switch (signChar)
                {
                    case "{":
                        nn = 0;
                        break;
                    case "A":
                        nn = 1;
                        break;
                    case "B":
                        nn = 2;
                        break;
                    case "C":
                        nn = 3;
                        break;
                    case "D":
                        nn = 4;
                        break;
                    case "E":
                        nn = 5;
                        break;
                    case "F":
                        nn = 6;
                        break;
                    case "G":
                        nn = 7;
                        break;
                    case "H":
                        nn = 8;
                        break;
                    case "I":
                        nn = 9;
                        break;
                    case "}":
                        nn = 0;
                        negative = true;
                        break;
                    case "J":
                        nn = 1;
                        negative = true;
                        break;
                    case "K":
                        nn = 2;
                        negative = true;
                        break;
                    case "L":
                        nn = 2;
                        negative = true;
                        break;
                    case "M":
                        nn = 4;
                        negative = true;
                        break;
                    case "N":
                        nn = 5;
                        negative = true;
                        break;
                    case "O":
                        nn = 6;
                        negative = true;
                        break;
                    case "P":
                        nn = 7;
                        negative = true;
                        break;
                    case "Q":
                        nn = 8;
                        negative = true;
                        break;
                    case "R":
                        nn = 9;
                        negative = true;
                        break;
                }
                final = Decimal.Parse(numb);
                //       Dts.Events.FireInformation(-1, "final 1", final.ToString(), String.Empty, 0, ref fireagain);
                final = (final * 10);
                //         Dts.Events.FireInformation(-1, "final 2", final.ToString(), String.Empty, 0, ref fireagain);
                final = (final + nn);
                //      Dts.Events.FireInformation(-1, "final 3", final.ToString(), String.Empty, 0, ref fireagain);
                final = (final / 10000);
                if (negative)
                {
                    final = (final * -1);
                }
                //      Dts.Events.FireInformation(-1, "final 4", final.ToString(), String.Empty, 0, ref fireagain);
            }
            return final;
        }
        private object ReadVariable(string varName)
        {
            object result;
            try
            {
                Variables vars = null;
                Dts.VariableDispenser.LockForRead(varName);
                Dts.VariableDispenser.GetVariables(ref vars);
                try
                {
                    result = vars[varName].Value;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    vars.Unlock();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return result;
        }
        private void WriteVariable(string varName, object varValue)
        {
            try
            {
                Variables vars = null;
                Dts.VariableDispenser.LockForWrite(varName);
                Dts.VariableDispenser.GetVariables(ref vars);
                try
                {
                    vars[varName].Value = varValue;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    vars.Unlock();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}


surabhi dave

Using the script component to cleanse data

$
0
0

I am relatively new to SSIS.

I have a SQL Server source and need to strip out all types of puncuation and empty space before I send it to my flat file destination.

I am using the Script component becuase it seems like this is a very powerful transform and learning it will give me lots of power and flexabilty on future projects.

Below is my C# script that clears out some types of puncuations, but I have seen better methods when I google "C#, Strip punuation from Strings", the only problem is I can't get them to work.

I thought I would post  the code I have thus far and see if anyone can improve on it.  I will post my improvemetns as I get them to work.

My next step is to use the Trim function to remove leading and trailing spaces if they exsist.

Any ideas or suggeston appreciated.

Mike

 public override void Input0_ProcessInputRow(Input0Buffer Row)
    {
        if (Row.Col3.Contains("."))
        {
            Row.test = Row.Col3.Replace(".", "");
        }
        else if (Row.Col3.Contains("-"))
        {
            Row.test = Row.Col3.Replace("-", "");
        }
        else if (Row.Col3.Contains(","))
        {
            Row.test = Row.Col3.Replace(",", "");
        }
        else
        {
            Row.test = Row.Col3;
        }
    }
}

Passing parametized SQL from a loop container to OLE DB source

$
0
0

I have a Foreach loop container that loops through 5 sql statements that are exactly like the one below except for the table name. These are mapped to a variable that a OLE DB source uses for its SQL command from variable. The problem is that I need to also map another variable as a parameter, and it appears 'SQL command from variable' mode in the OLE DB source only allows me to map parameters in SQL command mode only. How can I get both things (table name in SQL statement and value of parameter for st_period) to change with each iteration of the loop?

select account_number, outlet_number, dba_name, loc_address, case loc_city when '' then 'City unavailable' else loc_city end as loc_city from taxtype1 where st_period = ?


Visual Studio Excel Destination Specific Starting Row?

$
0
0

Hi,

I've been researching how to do this with not much success.  I have a visual studio loop that separates out account data from a master data table with multiple accounts.  It separates them out so each account has their own Excel file output in the standard way Visual Studio outputs to Excel.  Column headers with data underneath starting at row 1. 

I have a specific fancy report I need this to generate output to and I can't figure out how to do that.  Basically the Account in the normal account output is showing multipel times in column A, I just want it to show up in my second sheet in cell B4.  Then I want the account's transactional history to start showing in cell A13, not A1. 

Can anyone help me figure out how to do this?  I am VERY new to Visula Studio. 

HEADER DETAIL AND FOOTER IN C#

$
0
0

Hi,

I want an output as follow. i wrote script which gives me different output. should i connect script to dataflow task and get this output orelse write another script? if another script than how and what to write in script? Guide me please

RECORD ID

SEQUENCE NO

CONTRACT NAME

CONTRACT ID

AMOUNT

CHD

59

H1026

HEALTH OPTION

$6525

RECORD ID

SEQUENCE NO

CONTRACT NAME

CONTRACT ID

AMOUNT

DET

59

H1026

HEALTH OPTION

$6525

59

H1026

HEALTH OPTION

$6525

59

H1026

HEALTH OPTION

$6525

RECORD ID

SEQUENCE NO

CONTRACT NAME

CONTRACT ID

AMOUNT

CTR

59

H1026

HEALTH OPTION

$6525i


surabhi dave

Convert XML data field to a relational table

$
0
0

Hi

(SSIS 2008)

I have a table with the following structure

CREATE TABLE [dbo].[TimeSeries](
 [TimeSeriesId] [bigint] IDENTITY(1,1) NOT NULL,
 [TimeSeriesEffectiveDate] [datetime] NOT NULL,
 [content] [xml] NOT NULL
)

on which I would like to transform the xml data field into a relational table.

In my Ole DB Source:

SELECT TimeSeriesId, TimeSeriesEffectiveDate, content AS XMLContent
FROM dbo.TimeSeries
WHERE (lastupdate BETWEEN ? AND ?)

the structure of the xml data field is like this:

<TS><values v0="25" v1="25" v2="25" /><qualities v0="4" v1="1" v2="2" /></TS>

To convert this into a tabular form I have an OleDB Command where I will execute this

declare @xmlValues as xml
select @xmlValues = ?;
with V (id, ts, inx, val1) as 
( 
 select 
 ? as id,
 convert(smalldatetime, ?) as ts,
 convert(int, substring(x.value('local-name(.)', 'varchar(255)'), 2, 255)) as inx1,
 convert(decimal(18,4), x.value('.', 'varchar(255)')) as val1
 from @xmlValues.nodes('TS[1]/values[1]/@*') as T(x)
)
, Q(inx, val2) as 
( 
 select 
 convert(int, substring(y.value('local-name(.)', 'varchar(255)'), 2, 255)) as inx,
 convert(decimal(18,4), y.value('.', 'varchar(255)')) as val2
 from @xmlValues .nodes('TS[1]/qualities[1]/@*') as T(y)
) 
select V.id, V.inx, V.val1, Q.val2, DATEADD(hh, V.inx, V.ts) as ts 
from V left outer join Q on V.inx = Q.inx

The problem is the xml field. In the Ole DB command I can see that it is treated as a
Unicode text strean [DT_NTEXT] but if I create an External column of type NTEXT in the Ole DB Command task to hold the xml input I get the error VS_NEEDSNETMETADATA when I execute the task. I have tried to add a Data Conversion task to convert to other data types, but without luck.

What can I do to make this work?

/Paul S

Regarding ssis

$
0
0

HI,

Please send me to any real time tasks in ssis,ssrs, important topics, and project details 

SSIS Script Task

$
0
0

Hi,

I am new to ssis and want to learn more about Script task.can you please tell me the link or any e book which contains all the methods used in task.

Thanks in advance

Viewing all 24688 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>