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

SSIS Script to Write to Multiple Excel Worksheets, with Different Columns on Each Sheet

$
0
0
I'm trying to extend some of the solutions I've found here and in other SSIS reference websites.  I have been successful at writing multiple sheets in a workbook, where each sheet has the same data structure.  I am using SQL Server 2005.

What I would now like to do is have a "for each" loop container that processes information (including queries) that are stored in a SQL Server table.  Here is the structure of that table:

 

create table dbo.Monthly_Report_Queries
   (
   seq_num              real        not null
   , worksheet_name     varchar(32) not null
   , create_statement   varchar(400) not null
   , data_query         varchar(7500) not null
   )


The seq_num column is used to control the order of the queries (for my "for each" loop container); the worksheet_name column has a valid Excel worksheet name (31 or fewer characters) on which the data will be placed; the create_statement column has a valid Excel statement to create a worksheet with the desired column names and data types; the data_query column has a SQL Server T-SQL query to get from the database the information to place on the corresponding worksheet.

I have been successful at getting the worksheets created, and at getting a Script Task to the point where it executes the data_query and returns the results to the Script Task.  I am now stuck at deciding how best to use the Script Task to get the data onto the worksheet (or even how to get the Script Task to put the data there even in a poor way).

Here is my VB code so far:

' Microsoft SQL Server Integration Services Script Task
' Write scripts using Microsoft Visual Basic
' The ScriptMain class is the entry point of the Script Task.

Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.OleDb
Imports System.IO
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime


Public Class ScriptMain

	' The execution engine calls this method when the task executes.
	' To access the object model, use the Dts object. Connections, variables, events,
	' and logging features are available as static members of the Dts class.
	' Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
	' 
	' To open Code and Text Editor Help, press F1.
	' To open Object Browser, press Ctrl+Alt+J.

	Public Sub Main()
        '
        ' http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dts.tasks.scripttask.scriptobjectmodel.connections(SQL.90).aspx
        '
        Dim myADONETConnection As SqlClient.SqlConnection
        Dim command As New SqlCommand()

        myADONETConnection = _
            DirectCast(Dts.Connections("ORION.TRS1").AcquireConnection(Dts.Transaction), _
            SqlClient.SqlConnection)
        MsgBox(myADONETConnection.ConnectionString, _
            MsgBoxStyle.Information, "ADO.NET Connection")

        command.CommandTimeout = 30
        command.CommandType = CommandType.Text
        command.CommandText = CType(Dts.Variables("DataQuery").Value, String) ' Get query from DataQuery variable
        command.Connection = myADONETConnection

        ' Open the connection and execute the reader.
        ' myADONETConnection.Open() ' already open

        ' MsgBox(command.CommandText, MsgBoxStyle.Information, "About to execute...") ' examine the query

        Dim reader As SqlDataReader = command.ExecuteReader()

        If reader.HasRows Then
            Do While reader.Read()
                MsgBox(reader(0), MsgBoxStyle.Information, "Query output...")
            Loop
        Else
            MsgBox("No rows returned.", MsgBoxStyle.Information, "Query output...")
        End If

        ' myADONETConnection.Close() ' do not close; leave open

        Dts.TaskResult = Dts.Results.Success
    End Sub

End Class



I would appreciate any links to websites that will help me decide which connection manager to use for writing data from a Script Task.  (I am creating the worksheets in the For Each loop using an Execute SQL Task and an Excel Connection Manager.  Should I use an ADO.NET connection to the same Excel file to write the data from the Script Task?)  Are there better ways to get the query output than ExecuteReader()?  Would it help to put the ExecuteReader() output into an array, and maybe use some form of VB command to place the entire array on the worksheet (rather than "cell by cell")?  (I never expect to have more than a few hundred rows returned by any one of the queries.)

Thanks for your help with this -- and for the many wonderful postings I have found on the Web that have helped me so far.

Dan
 


Error when run with a different userid/on different server

$
0
0

This is related to SSIS 2005

There is table which stores connection information. It is fetched correctly and passed on to the connectionstring dynamically to OLEDB connection, in Development and test Servers. When used with other valid user( who has permissions), it is failing in Production, if we don't change the default value that is equivalent to configuration table.

Details

1. The default connection( stored in the variable window ) has 'Server A', the config table has 'ServerB', when prod account is used, it is not going to 'server B'(confirmed through profiler), not sure if it is going server A either. However when default information is also changed to 'Server B' then it is working.

2. On the Production Server Itself, without  any changes to default values in the variables, with another useraccount, it is able to get data from 'ServerB' correctly

Running as a jobstep. but behaviour is same even if you run from BIDS. Deployed the package in msdb using import option and configured a job step to use this

Both users have the same permissions.

I remember somewhere long back that there is a bug in ssis,The default values in the connection manager should have been executed atleast once with the user, if the configured values is different, is that correct? any links


Error:

Executed as user: abc\bcd. ...on 9.00.522.00 for 64-bit  Copyright (C) Microsoft Corp 1984-2005. All rights reserved.    Started:  10:00 PM  Error: T    Code: 0xC0202009     Source: abc Connection manager "abcd"     Description: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80004005.  An OLE DB record is available.  Source: "Microsoft SQL Native Client"  Hresult: 0x80004005  Description: "Login failed for user abc\bcd.".  An OLE DB record is available.  Source: "Microsoft SQL Native Client"  Hresult: 0x80004005  Description: "Cannot open database "adventure" requested by the login. The login failed.".  End Error  Error: 2009-12-22 15:04:52.16     Code: 0xC020801C     Source: Data Flow Task - tblBicyles OLE DB Source [1]     Description: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER.  The AcquireConnection method call to the connection manager...  The package execution fa...  The step failed.

Thanks in advance
Pra

DependencyAnalyzer

$
0
0
hi

I downloaded and installed  DependencyAnalyzer.exe,  when i ran against SSIS package.   if source and target SQL Server, i am getting correct data, if source is SQL Server and Target is AS/400 or  source AS/400 target SQL Server, it is getting data. but when i ran exe, it say package name and completed successfully. 

is any setting i am missing in SSIS package,   my SSIS very simple , straight  forward.  connection i am using is OLE DB  IBM driver,  package is working fine.      i am not using variables to pass table name or conection strings.

can anyone help me to resolve the issue

thanks
v

Package Path missing from Package Installation Wizard

$
0
0

When I run the Manifest to install my SSIS packages, the Package Path field is missing from the "Specify Target SQL Server" step of the wizard.  When a co-worker runs the same Manifest, the field shows up for him.

We have Bing'd all over for this but haven't found anything.  Why would this field be missing for me and not for him?

Thanks,

SSIS foreach Loop - creating dynamic log output files and sending email

$
0
0
Hello All,

I am having a problem in implementing the following scenario:

I have to run scripts against my databases using SSIS package and SQL agent job. This package is deployed on server and a SQL agent job is defined which runs every 5 min.

I want to create dynamic log output files when a particular script is run against my database and if the script fails it needs to send email with the log file attached.

What I have implemented is:

created a foreach loop container -> pointed to pick up *.sql files and then defined a move file system task to move the file to a different folder, to mark it as run.

This is running fine. but want to enhance some more so that I can put in the dynamic log file generation if the script fails and then email that log file to the user.

Any reference or ideas are appreciated !

Present setup:
here is what is set up now and is working fine.

There is a folder for each DB server, under that are the DBs folders.
The script file is dropped in the directory with the Data base name against which the script
will run and the there is a SQL agent job that will pick it up and run it.

Also the file has a .sql extension.
The job kicks off every 20 mins and will check the directory for valid scripts and run them once they are complete it moves the script files to a separate directory.

** I am enhancing this process to include detailed logging for the failed scripts and email the log files to concerned group.
But when implementing rt clk on control flow ->logging -> SSIS log provider for text files --> connection (log.txt). some how it is generating 2 log files. I have defined an expression for that:
"G:\\SSISTest\\ScriptRunner\\Failed\\" +  @[User::filename]   +
(DT_STR,4,1252)DATEPART( "yyyy" , @[System::StartTime]   ) +
RIGHT("0" + (DT_STR,4,1252)DATEPART( "mm" ,  @[System::StartTime]  ), 2) +
RIGHT("0" + (DT_STR,4,1252)DATEPART( "dd" , @[System::StartTime]   ), 2) +
RIGHT("0" + (DT_STR,4,1252)DATEPART( "hh" , @[System::StartTime]   ), 2) +
RIGHT("0" + (DT_STR,4,1252)DATEPART( "mi" ,  @[System::StartTime]  ), 2) +
RIGHT("0" + (DT_STR,4,1252)DATEPART( "ss" , @[System::StartTime]   ), 2) +
".txt"

I want the log file as userFilenamedatetime.txt
Note: the userfilename is the file which ran against the db's. meaning it is not defined what the user will name (but it will have .sql extension)

Thanks,

\\K

SSIS Debug Host has stopped working

$
0
0
Well that's the title of the messagebox i'm getting once my package in SQL Server Business Intelligence Development Studio has completed.
The package runs successfull on my laptop, but now I've re-created it on a server and I get this problem. It actually runs and imports all the rows that are needed, but it fails in the end.

You'd say, no problem if it works ... but I'm using this package in my agent as 1 step and there will follow more steps. So I'd have to enable "go to next step on fail" ... but I want automatic mailing to my own email adress on fail and like this i'll always get mailed ...

Anyway, here's the error:
"SSIS Debug Host has stopped working"
I can check online for a solution ... close or debug the program.
Extra details:
Problem signature:
Problem Event Name: APPCRASH
Application Name: DtsDebugHost.exe
Application Version: 2007.100.1600.22
Application Timestamp: 48753d31
Fault Module Name: StackHash_9cb9
Fault Module Version: 6.0.6002.18005
Fault Module Timestamp: 49e03821
Exception Code: c0000374
Exception Offset: 000afaf8
OS Version: 6.0.6002.2.2.0.274.10
Locale ID: 2067
Additional Information 1: 9cb9
Additional Information 2: 7d6ff1a72252a7c1c69569fdf100cb8a
Additional Information 3: 551c
Additional Information 4: b4f6c651c3642a00be6c30e327386768

Read our privacy statement:
http://go.microsoft.com/fwlink/?linkid=50163&clcid=0x0409



Anyone?

I'd be most gratefull.

-Yakkity

OLE DB Error when connecting to AS/400, Iseries to call a program

$
0
0
I get the below error when attempting to connect to an AS/400 to call a program:

An OLE DB error has occurred. Error code: 0x80040E21.  End Error  Error: 2009-10-21 08:47:02.12     Code: 0xC00291EC     Source: Execute SQL Task Execute SQL Task     Description: Failed to acquire connection "A4110109.A4110109.rtftp1". Connection may not be configured correctly or you may not have the right permissions on this connection

The connection string looks like this:

Data Source=MYAS400;User ID=myuserid;Password=mypassword;Initial Catalog=MYAS400;Provider=IBMDA400.DataSource.1;Persist Security Info=True;LibraryList= MYLIB1, MYLIB2, MYLIB3, MYLIB4, MYLIB5;

I can connect to the AS/400 and transfer data back and forth all day long, as I do in many other packages.  But in this case I am using an Execute Sql Task to call a program on the AS/400.  I was previously doing this successfully in DTS.  It works fine when I run it on my local machine but once I schedule it on the server it fails.  I can take the "Library List" option off and it will attempt to call the program but fails since it cannot find all of the AS/400 objects that exist in the library list. 

Since it works on my development machine could this be a provider version issue?  The server actually has a later version of the .net db2 providers installed. 

My machine has mdac version of 2.81.1132.0 while the server has 2.82.3959.0

Any ideas are appreciated.

Thanks

SSIS job does not run

$
0
0

I have a job scheduling issue and kept getting the

“Internal request (from SetJobNextRunDate [reason: schedule will not run again]) to deactivate schedule 15.” message in the error log. 

I am scheduling the job on my developer machine.  The package runs fine either within BIDS or outside of BIDS.  I tried the File System, SSIS, and the SQL Server options and all of them yielded the same sad result.  

In the job Step, I defined the configuration file in the Configurations tab and I checked all the boxes in the Data Sources tab.  Am I missing anything here?

Any pointers will be appreciated.


BI Analyst


Remove duplicate rows

$
0
0

I had a .txt file with 6571 rows and 250 columns

The account numbers in the Account_Number column were flawed and I had to fix them using some transformations.

But at the end the OLE DB Destination where I populated a table I can see 9004 rows.

I used select distinct on the account numbers to see the destination table and it seems the rows have repeated because of repeating column numbers.

what transformations can I use in SSIS to get rid of duplicate account number rows?


Dhananjay Rele

SSIS DFT Problem

$
0
0

Hello ,

I am working on SSIS package,
environment : BIDS 2008.
I am using a data flow task, that contains one excel source component at the start.
excel source component reads file & then we are doing other validation on data, that is OK
but if that component fails, I want to insert a record into SQL table (SQL 2008).
I am trying with "OLEDB command" component, "OLEDB Destination", "SQL Server Destination"
as an error output to "excel source" component. but it is not working. as soon as excel source component has error(turns red) then it does not move further.
even if I changed the setting of error output to "redirect row"it is not working.

can anyone please help.

Deploy SSIS Package with Oracle DB (ADO.NET Connection)

$
0
0

When deploy the SSIS package to windows SSIS Server, the issues found due to the Oracle DB connection thru ADO.NET Connection Manager. 

The package configuration was created. Even though I typed the password in the config file, it still cant connect the Oracle DB. The protection level of the package is "Don'tSaveSensitive"

Error Message: 

1073450910,0x,System.Data.Odbc.OdbcException: ERROR [28000] [Oracle][ODBC][Ora]ORA-01005: null password given; logon denied

ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed
ERROR [28000] [Oracle][ODBC][Ora]ORA-01005: null password given; logon denied

   at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode)
   at System.Data.Odbc.OdbcConnectionHandle..ctor(OdbcConnection connection, OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle)
   at System.Data.Odbc.OdbcConnectionOpen..ctor(OdbcConnection outerConnection, OdbcConnectionString connectionOptions)
   at System.Data.Odbc.OdbcConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
   at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
   at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   at System.Data.Odbc.OdbcConnection.Open()
   at Microsoft.SqlServer.Dts.Runtime.ManagedHelper.GetManagedConnection(String assemblyQualifiedName, String connStr, Object transaction)
   at Microsoft.SqlServer.Dts.Runtime.Wrapper.IDTSConnectionManager100.AcquireConnection(Object pTransaction)
   at Microsoft.SqlServer.Dts.Pipeline.DataReaderSourceAdapter.AcquireConnections(Object transaction)
   at Microsoft.SqlServer.Dts.Pipeline.ManagedComponentHost.HostAcquireConnections(IDTSManagedComponentWrapper100 wrapper, Object transaction)


wailun3

new to ssis - Lookup - is it possible to perform like outerjoin or any other joins

$
0
0

hi all

am new to ssis

i created one simple package with lookup

table 1 with  2 fields (id and country name)

id countryname 

1 ind

2 china

3 japan

table 2  only one field country name

country name

ind

Eng

USA

am reading data from oledb source thn i created one lookup its workin fyn also

but its performing like inner join, 

is it possible to perform like outerjoin or any other joins ???

suggest me some ideas

thanx in advance





SSIS To Oracle Via LDAP Connection

$
0
0

In SSIS, How to connect to Oracle database using LDAP method.

Thanks

Raj

Multiple simaltaneous update in custom log table from SSIS package.

$
0
0

Hi,

I have a custom log table in sql server database. which recording the SSIS package activities(each task execution time, statuses...) when this table is going to use simultaneously multiple time it's not going to  update data properly. but it's inserting the records for all packages which is the start of the task but not updating it's status which is the last task in each package.

i have a master package which call all executable packages . master package design parallel so all packages are executing parallel. it's 8 core machine.

behaviours is unpredictable, some time it's update for all packages. some time it's wont update the 2 or 3 packages remain will update appropriately.

can anyone please provide pointer so I can fix this issue.

Thanks in advance.
Zaim Raza.


http://zaimraza.wordpress.com/

How can I change my Execute SQL task setting to behave like SSMS and continue dispite errors

$
0
0

My insert below in ssis produces 26 rows, vs. 86 in ssms. I assume it timesout but I am not sure?

I'd like to get the same behavior. I changed MaximumErrorCount to 10000, but it didn't make a difference.

In both cases the insert fails for tables that don't have a Date column. But I am not concern about these failures and errors.

exec sp_MSforeachtable 
   'insert into max_date_in_db_tables(tablename, updated, maxdate) select ''?'', getdate(), max([Date]) from ?',
@whereand = 'and o.name like ''%'''

My task settings:

  1. delayValidation True
  2. DisableEventHandlers True
  3. FailPackageOnFailure False

I am using Microsoft Visual Basic 2008. The links below are related but don't provide a solution.


see in which record the error occurred

$
0
0

Hi,

If I have Data Flow task and in that one source and one destination, at the time of execution if                                           there is any error occurred how would you see in which record the error occurred.


upsert

$
0
0

Hi,

If I have 100 records in source in that 90 are new rows and 10 are existing so how would u update existing rows in destination 

conditional executing tasks

$
0
0

Hi,

 If I have four tasks (T1, T2, T3, T4), after Successful execution of T1, (T2, T3) should execute and if any one failure of (T2, T3)       T4 should execute


Failed to Load OCI.dll error for Attunity for 64 bit SSIS and 64 bit windows 7

$
0
0

Hi guys i have tried all the possibilities of resolving this error also went to registry for this but in vain.

Can anyone help me with this

Thanks in advance.

DTSxxxx90 and xxxx100 in one project

$
0
0

hello all,

right now we're dealing with migration from ssis2005 to 2008 and we have some c# sources where we use quite a lot DTSxxxx90 intrefaces. To move to ssis2008 we have to change it to xxxx100 versions (and of course add references to 2008 dlls).

But we would like to have for some time the same sources before finally migrating to 2008. One solution is to use old technique #if/#endif and to compile the project according to target ssis version. But that means adding #if/#endif to every place where interface is used which will be not very nice (although working) solution.

Can anybody suggest some good solution for this kind of problem?

 

For example, function like this:

public void AddCustomProperty(IDTSInputColumn90 inputColumn, string name, string description, object value, bool supExp)
{
           

            IDTSCustomProperty90 customProperty = inputColumn.CustomPropertyCollection.New();
            SetCustomProperty(customProperty, name, description, value, supExp);
}

 

can be rewritten like this:

 

#if SQL_2005

public void AddCustomProperty(IDTSInputColumn90 inputColumn, string name, string description, object value, bool supExp)

#else

public void AddCustomProperty(IDTSInputColumn100 inputColumn, string name, string description, object value, bool supExp)

#endif

{           

#if SQL_2005

            IDTSCustomProperty90 customProperty = inputColumn.CustomPropertyCollection.New();

#else

            IDTSCustomProperty100 customProperty = inputColumn.CustomPropertyCollection.New();

#endif

            SetCustomProperty(customProperty, name, description, value, supExp);
}

 

And that is not very nice :(

 

We've already tried inheriting interfaces, but that does not work either (you cant downcast after in the code from IDTSOutput90/100 to IDTSOutput_X)

#if SQL_2005

    public interface IDTSOutput_X : IDTSOutput90 { };
    ...
    ...

#else
    public interface IDTSOutput_X : IDTSOutput100 { };
    ...
    ...
#endif

for example this will not work i think:

IDTSCustomProperty_X customProperty = (IDTSCustomProperty_X) input.CustomPropertyCollection.New();

New is giving IDTSCustomProperty90 or 100, depending on version of ssis.

 

Any ideas?

thanks

Viewing all 24688 articles
Browse latest View live


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