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

How to run C# code in SSIS script task.

$
0
0

Hi Team,

Am using to execute bellow C# code console application it is working fine but when am using script task to execute bellow C# code am getting error. Please help this issue ASAP.

My code:

#region Namespaces
using System;
using System.Data.SqlClient;
using System.IO;
using System.IO.Compression;
using System.Text;
using System.Xml;
#endregion

namespace ApiProfiler
{

    class Program
    {
        static void Main(string[] args)
        {
            SqlConnection con;

            SqlDataReader reader;

            try

            {
                string connection = System.Configuration.ConfigurationManager.ConnectionStrings["Profiler"].ConnectionString;


                con = new SqlConnection(connection);
                con.Open();

                reader = new SqlCommand("SELECT TOP 100 profilerId,requestXML,responseXML FROM Profiler order by 1 desc", con).ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        // WriteAllText creates a file, writes the specified string to the file,
                        // and then closes the file.    You do NOT need to call Flush() or Close().

                        string xmlRequest = Unzip((byte[])reader["requestXML"]);
                        XmlDocument docRQ = new XmlDocument();
                        docRQ.LoadXml(xmlRequest);
                        string jsonRQ = Newtonsoft.Json.JsonConvert.SerializeXmlNode(docRQ);
                    }
                }
                else
                {
                    Console.WriteLine("No rows found.");
                }
                reader.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }


        public static void CopyTo(Stream src, Stream dest)
        {
            byte[] bytes = new byte[4096];


            int cnt;


            while ((cnt = src.Read(bytes, 0, bytes.Length)) != 0)
            {
                dest.Write(bytes, 0, cnt);
            }
        }

        public static string Unzip(byte[] bytes)
        {
            //using (var msi = new MemoryStream(bytes))
            using (var mso = new MemoryStream())
            {
                using (var gs = new GZipStream(new MemoryStream(bytes), CompressionMode.Decompress))
                {
                    //gs.CopyTo(mso);
                    CopyTo(gs, mso);
                }


                return Encoding.UTF8.GetString(mso.ToArray());
            }
        }
    }
}


Thanks Bala Narasimha


SSIS package called from SQL job setup in 32 bit mode calling dll's of 64 bit

$
0
0

There is a package created in a solution to read the Flight Recorder trace file.

To execute this package, SQL server Agent job is calling this dtsx and setup with 32-bit runtime.

Its running fine on Test server, but failed on Pre-Production with below error:

Microsoft.SqlServer.Management.Trace.SqlTraceException: Failed to initialize object as reader. ---> System.IO.FileNotFoundException: Could not load file or assembly 'file:///F:\Program Files\Microsoft SQL Server\120\Tools\Binn\pfclnt.dll' or one of its dependencies. The system cannot find the file specified.

This dll is available in F:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn in both environments.

Not able to understand, why 32-bit mode is calling dll from 64-bit folder location

Note: In the SQL server job , there are 3 packages being called, 1 and 3 being executed with 64-bit mode and 2nd with 32-bit mode (which is throwing error) 

Could anyone please suggest on this.

Child package dynamically change variable value when called from parent

$
0
0

I am working on an SSIS solution that contains several master packages that execute other packages via Execute Package Task. Using SQL Server 2016 and Vistual Studio 2017 Data Tools edition.

The child packages can be executed individually or thru a master package. I am using the Project Deployment model, can't use the Package Deployment model because it breaks parameters and other stuff.

What I want to accomplish is for the child package to be aware if it's executed by itself (w/o the parent) and adjust the connection string of an Excel file connector. If child package detects that it is running called from the parent than modify the connection string. So far, I managed to create a Parameters Binding on the Execute Pack Task in the Parent package, I am able to successfully pass the Excel file's path from parent to child, and child executes successfully and generates the file. This works because binding is pointing to a Package Parameter in child, but, when child executes by itself it fails because it has no value so Excel connector can't find the file/path. I tried passing thru binding the Parent variable to another child variable (which has an expression that allows to run child independently), but then child always generates Excel file in the same location regardless of executing by itself or called from a parent.

Basically, if I use an expression tied to a Package variable, I can't replace it's value with Parameter Binding. If I use a Package Parameter on child then Parameter binding works, but child package would not run by itself (only when called from parent). Is there a way, maybe thru a Script Task, to determine if child has been called/executed from parent? My idea is that maybe thru Script Task I can adjust my variable to the correct path.

This works (Parent maps to a child's Parameter) when calling child, but child doesn't work on it's own

This always works (Parent maps to child's variable), but child always uses it's own value for Excel connector regardless of Parent Param Binding


Adrian Hernandez



Changing excel data types

$
0
0

Hi there

I am a novice with SSIS and want to create package which uploads an excel spreadsheet into sql server.

However, one of the fields in the spreadsheet needs changing to a date field, also it is possible that the first entry in this field is blank. Obviously I could manually change the datatype in the spreadsheet and enter a value on the top row but as I'll be uploading this file frequently, I would like the SSIS package to do it for me.

Is there any way of doing this?

Thanks,

Andy

Preserving Numeric Data Type while writing to CSV output

$
0
0

Hi,

In my dataflow on a high level I am reading the data from Oracle and send the output to a flat file (.csv).

There is a particular column that has a Data type of Number (12,5) in Oracle. SSIS is implicitly converting it into DW_STR.

For this particular column there is no business requirement for any sort of Transformations, it just simply writes the data out to the .csv file.

However when writing to the .CSV file, the data type changes to String (Format -General if you open in Excel). I am required to keep the format as Numeric. I have tried a bunch of things including using implicit data conversion (to convert to Number/Decimal), editing the metadata to change the data. However nothing seems to work. There are other similar columns in the database that I am able to write as Number to the .csv file using the DT_R8 datatype. However for this particular column it does not work. 

Any pointers?

Getting occasional error 15404

$
0
0

I have several SSIS packages that run on the hour...been that way for years...when I upgraded our infrastructure to Server 2016 a few years ago I started to see some:

[298] SQLServer Error: 15404, Could not obtain information about Windows NT group/user...

...over the course of a day I'll see maybe 3-5 occurrences of this error with ~25 successful...also - when I run the package from my workstation it ALWAYS works...I have a physical AD, a vm AD on-premises, and a vm AD in our Azure extended domain...very puzzling. Anybody got a clue?

C# Reference variable from Main method in another method

$
0
0

Hi, I am trying to reference a variable from Main method in a different method and I am not sure how to do this. Could you please help me out.

using System.IO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    public void Main()
    {
        var game = "game 10";
	var score = "25";
    }

    public class result
    {
        var gamenumber = Main.game; //access the variable game from main method
	var scorecard = Main.score; //access the variable score from main method
    }
}

Thanks in advance.


SQLEnthusiast


How To Fix PFCLNT.DLL is Missing / Not Found Error Messages

$
0
0

Hi Team,

I have sql server 2014 64 bit installed on ms windows 2012 r2. I have and SSIS package where i am trying to read sql trace file and getting below error.

'file:///C:\\Program Files\\Microsoft SQL Server\\120\\Tools\\Binn\\pfclnt.dll' when i checked on server file was missing there. It works fine in case of if sql server is installed for 32 bit also on another machine. But as per requirement we have to solve issue for 64 bit installation and in package setting it is also set to 64 bit. Run in 32 bit checkbox is unchecked there.

In C# code Microsoft.SqlServer.ConnectionInfoExtended is referenced and something like below code is used.

TraceFile tf = new TraceFile();

string trcFile = @"xxxx.trc";tf.InitializeAsReader(trcFile);

As per my understnding ConnectionInfoExtended.dll is only for 32bit and do not work when package is executed in 64 bit enviornment and file is also missing.

Please let me know how this can be fixed for 64 bit setup.

Thanks & Best Regards,

Pradeep Kumar



Execute pacakge task error.Error 0xC0012050 while preparing to load the package.Package failed validation from the ExecutePackage task. The package cannot run.

$
0
0

Hi I am getting below error,when I am executing parent pacakge.If I run child packages individually,then they are working fine.I ahve problem with parent pacakge only.

 Error 0xC0012050 while preparing to load the package. Package failed validation from the ExecutePackage task. The package cannot run.
.


sudha

SSIS Web Service Task - Error 301 Moved Permanently

$
0
0

Dear SQL Server users,

I'm connecting to a webservice from inside an SSIS package (in Visual Studio 2017).

When I click the test connection button in the THHP Connection Manager Editor, it says, "Connection Succeeded"! So my credentials are definatelly correct.

But when I execute my Web Service Taks, it fails with error 301 Moved Permanently.

I'm a bit of a novice when it comes to webservices, so I don't know what to do. It looks as if I'm addressing the wrong URL, because it says it has been moved, but I'm pretty sure the the URL is correct. because I can succesfully test the connection and also, the web service component is configured correctly (No configuration errors, because they would be visible)

What should I do?

Connecting from SSIS to MySQL Database using OLEDB Source

$
0
0

Hi All,

I have MySQL data source and want to perform ETL using SSIS.  I can connect to mySQL using ADO NET Source  but not using OLEDB source.
The most of the SSIS components  like LookUp,Fuzzy Grouping ,Fuzzy Lookup  , Term Lookup etc  only allow   OLEDB Connection manager to connect to database.  

Any  Microsoft OLE DB Provider for MySQL available ?

Is there any way to connect to MySQL   using OLE DB  Connection Manager  from SSIS?


Thanks,

Moz

 


Connecting from SSIS to MySQL Database using OLEDB Source

$
0
0

Hi All,

I have MySQL data source and want to perform ETL using SSIS.  I can connect to mySQL using ADO NET Source  but my requirement is to use OLE DB source.

Any  Microsoft OLE DB Provider for MySQL available ?

Is there any way to connect to MySQL   using OLE DB  Connection Manager  from SSIS?

Thanks,

Issue while upgrading SSIS 2008 packages to SSIS 2016

$
0
0

Hi,

I am working on SSIS upgrade (2008 to 2016). I have easily upgraded SSIS 2008 to 2016 packages where there is a SQL database connectivity.

But I am facing issue with upgrading with Oracle database connectivity. There are few points 

1. I have installed Attunity 5.0 on my machine

2. Still I am not able to see MSORA  Microsoft Connector for ORACLE by Attunity option in New Connection

3. I have tried with "Microsoft OLE Provider for Oracle" getting following error

TITLE: Connection Manager
------------------------------
Test connection failed because of an error in initializing provider. Oracle client and networking components were not found. These components are supplied by Oracle Corporation and are part of the Oracle Version 7.3.3 or later client software installation.
Provider is unable to function until these components are installed.

but I am able to connect to database with TOAD

4. When I am opening my packages in Visual Studio 2015 for upgrade process, it is not opening 

Could you please suggest ,

how to overcome on this issue or any additional driver or software is required?

Excel Connection Manager is not connecting to my spreadsheet

$
0
0

When I try to select from the dropdown I get the following error:

I think this is an issue to my version.  

Possibility to install only the SSIS 2012 by avoiding the full license cost of SQL Server 2012

$
0
0

Hi Team,

Is there any possibility to install the SSIS alone in one server, by avoiding the full license cost of SQL Server.

Is there any possibility to install SSIS only, by paying only the license cost of SSIS?

I am asking this options, because of the below situation, Kindly help with your valuable suggestion......!

We have three applications running (say X,Y and Z), in production. All using SSIS Package and SQL Server as DB. Now the prod server performance is degrading due to high resource contention. So we thinking to migrate the application 'X', from the existing Prod server to a new dedicated server where the DB should be 'PostGreSQL'. The DB change is due to save the License Cost of SQL Server. Also the ETL packages which is currently in SSIS, is little complex so we are not migrating that to any Open source considering high development cost :) .


How to load weather data into a sql server table

$
0
0

Hi All

Can someone please point me to a link or document which has step by step process of loading weather data from internet to a sql server table?

Thanks

SSRS expression

$
0
0

Hi,

I have the report to show the due date for the orders: late, due today, due tomorrow.  For due tomorrow , I don't want to include the weekend.  For example, if the report send out on July 5, the tomorrow due date will be July 8.  I am not sure how to put together the syntax, can anyone help please?

Thanks

=IIF(Fields!duedate.Value<Today(),"Late" 
 IIF(Fields!duedate.Value=Today(),Due Today" "+
 IIF(Fields!udedate.Value>Today(),Due Tomorrow" 
)))

SSIS version

$
0
0

What is the LastModifiedProductVersion mean?

Is it the SSIS version of the SQL server or is it the version of the SSDT tool?

What is the version of below two mean?

  DTS:LastModifiedProductVersion="14.0.3002.101"

 DTS:LastModifiedProductVersion="15.0.0900.30"

.

Thanks


SQLFriend

Executing an SSIS Package Via Excel Macro

$
0
0

Good afternoon, all -

I have an Excel macro that does various preprocessing tasks on an Excel file; it corrects some formatting, does some minimal auditing and then dumps the file to a To Be Processed folder.

Once all that is done, I then run the file through SSIS to update a database that we use to access the data. This is a daily process and I'd like to minimize human contact, so I wondered if I'd be able to run the SSIS package from an Excel macro.

In doing some searching the 'net, I came across some discussion on what I'm looking for and I've come up with a code snippet that is maybe what I want. But, not being totally sure, I thought I'd pass it by here, before I risk it;

Sub Exec_SSIS()
    Dim sSSIS As String
    sSSIS = "dtexec /f ""C:\Process_Census.dtsx"""
    Call Shell(sSSIS, 0)
End Sub

This seems awfully simple, so I'm figuring I'm missing something - although, it might be a simple process, overall.

Is this a working set of code? And, if it is, will it return control back to Excel when the SSIS package is complete, or does it remain in SSIS?

Or, have I taken a hard turn out onto Death By a Thousand Cuts Lane?


The column "COLUMNNAME" cannot be processed because more than one code page (65001 and 1252) are specified for it.

$
0
0

when I try to import the csv file into an existing database , the following error is coming

I did the following steps

1. Select flat file source

2. Filename .csv file

3. Destination SqlServer Native client 11.0

4. Sql Authentication and given username and password

5. I selected Append rows to the destination table

6. After that , I click finish button ' the error is coming  

Messages
Error 0xc02020f4: Data Flow Task 1: The column "COLUMNNAME" cannot be processed because more than one code page (65001 and 1252) are specified for it.
 (SQL Server Import and Export Wizard)

Please any help


polachan

Viewing all 24688 articles
Browse latest View live


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