Showing posts with label package. Show all posts
Showing posts with label package. Show all posts

Monday, March 26, 2012

How to remove {CR}{LF} and Tab {t} characters from source data?

I have built a SSIS package that reads in data from a SQL Server 2005 source database into a flat file destination. The Row Delimiter is {CR}{LF}. The Column Delimiter is Tab {t}.

The data being read from the SQL Server database contains both {CR}{LF} and Tab {t} characters in various fields on several rows.

How can I process the input data from the SQL Server to remove these characters before passing it to the destination output file?

Sorry if this is obvious to all, but I am only just starting with SSIS...

Many thanks

Adrian

If you have the data in a DT_STR ro DT_WSTR column, you can use the Derived Column transform with a REPLACE() function to replace those characters with empty strings.

Otherwise, you might want to use a Script component.

Thanks
Mark

Friday, March 23, 2012

How to refresh Access Table from SSIS package?

Hi all,

I have created an SSIS package to export rows of data from SQL to Access using SSIS package. The package is executed from asp.net web application. Below is what i want to achieve:

-User enters a date range

-SSIS package will export data between the date range from SQL to Access database.

-When user enter another date range, I want to clear the contents of the Access database. (Im using Execute Sql Task-- Delete tablename)

The problem is that when I look at the table after the second user request, the fields will show #deleted. Only after i click refresh will the new data appear. How can I make the data appear without manually refreshing the Access table.

Thks alot.

Can't you just drop off the access table and re-create it upon every user request ?

|||

Hi,

dropping the table means that I will need to create a the table again at the OLE DB destination. However I am unable to do that. I tried to use SQL command data access mode to create table. However, I received an error "CREATE TABLE SQL is not supported".

|||

Hi,

if it is not possible to refresh the Access table, can any expert here advise me on how to create a table when executing the package? The only way to go now is to drop the table and create a new table to solve my problem, but i am facing this problem of creating table.

Thks

Monday, March 19, 2012

How to redirect a DTS package and connections

Hi,

I have a DTS package (SQL2k, sp3) that I can to execute agains a new
database in the same server. I don't see how to easily redirect. If you
change the connection properties and clear the transformations you have to
redo them one at a time (too long).

If you don't data still goes to the old database.

What to do?

Sd"SD" <npspam@.nowhere.net> wrote in message
news:483161980e01c04754af03e36c264ae2@.news.teranew s.com...
> Hi,
> I have a DTS package (SQL2k, sp3) that I can to execute agains a new
> database in the same server. I don't see how to easily redirect. If you
> change the connection properties and clear the transformations you have to
> redo them one at a time (too long).
> If you don't data still goes to the old database.
> What to do?
> Sd

Check out the dynamic properties task - it allows you to set any properties
dynamically as the package is running. In this case, you could have a global
variable to store the database name, and use the task to assign it to the
connection. At runtime, you can pass the value for the global variable to
dtsrun.exe, or get it from an .INI file or SELECT query.

Simon

Monday, March 12, 2012

How to read/write global package variables in an active x script?

Is this possible. How can one do it? Thanks for any info you have.

Are you using DTS or SSIS? This is an SSIS only forum, if you're using DTS.

Stay away from Active X scripts in SSIS as that is a deprecated technology.|||Using SSIS. I know I shouldn't, but I have some legacy DTS code I need to quickly move over. Is it possible to read variables from an active x script? Thanks.

Friday, March 9, 2012

How to read the names of package variables in custom task

Hi there,
I found a lot posts about package variables. But nothing about how getting access to the
names of the package variables programatically.
Why? - Well I want to create a list of variable names from which the user can choose
one of in a UI of a custom task. That's all... :)
I thought of using the variable dispenser in the Initialize method of the task and then storing the variable names into a property which can be read by the UI through the taskhost.
But it seems that you have to know all your variables by name if you want to use then in a task.
Any idea?
Fridtjof
In your IDtsTaskUI.Initialize method, capture the TaskHost. Store it in a field and pass it through to the form within GetView. To get a list of variables in the form, just use the Variables collection that is exposed on the TaskHost.
|||Thanks again Darren,
I got confused by the VarableService which is available from the IServiceProvider in the contructor of the UI form which does not lead to a solution.
I found some sample code in BOL to read out the variable names:
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.SQL.v2005.en/dtsref9mref/html/P_Microsoft_SqlServer_Dts_Runtime_Variables_Item_1_b4c5a2da.htm
CU
Fridtjof
|||

You should use the LockForRead when accessing them from the component class. However, on the UI it is easiest to "Variables vars" collection to access the SSIS Package Variables.

e.g. vars["Name_Of_Variable"].Value

Stuart

How to read the names of package variables in custom task

Hi there,
I found a lot posts about package variables. But nothing about how getting access to the
names of the package variables programatically.
Why? - Well I want to create a list of variable names from which the user can choose
one of in a UI of a custom task. That's all... :)
I thought of using the variable dispenser in the Initialize method of the task and then storing the variable names into a property which can be read by the UI through the taskhost.
But it seems that you have to know all your variables by name if you want to use then in a task.
Any idea?
FridtjofIn your IDtsTaskUI.Initialize method, capture the TaskHost. Store it in a field and pass it through to the form within GetView. To get a list of variables in the form, just use the Variables collection that is exposed on the TaskHost.
|||Thanks again Darren,
I got confused by the VarableService which is available from the IServiceProvider in the contructor of the UI form which does not lead to a solution.
I found some sample code in BOL to read out the variable names:
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.SQL.v2005.en/dtsref9mref/html/P_Microsoft_SqlServer_Dts_Runtime_Variables_Item_1_b4c5a2da.htm
CU
Fridtjof

How to read the content of DTS local package?

I create a local package in DTS a few months ago. And set a schedule to run daily. Now i need to modify. How to read the content of DTS local package? i try to right click the package in job, and edit, but i didn't see the content. How can i see it and modify. Why mine can't be read? Thanks.you need to go under :

Data Transformation Services ->Local Packages in Enterprise manager.

You'll see your package there.|||I can find the package, But i want to see the content. As this is a package that import some of data from another database. So i can't read the content that means the query. I forgot, but i need to modify. Thanks.|||YYU I think SQL SERVER 2005 has a utility that allows you to SEE/EDIT your DTS file, regarless of the version used to create this files.

You can also try to monitor the activty on your SQL SERVER using the PROFILER TOOL, wich comes with SQL SERVER 2000+, and run your DTS files. Your SQL QUERY should appear in your TRACE FILE.

BTW this forum ROCKS!!

BIGGGG UP!!|||Thanks. It is great to have sql server 2005. We will have later. Let's see.

Thanks again!

How to read sql tasks and so on from a package programmatically?

Hi everyone,

Once I've accesed to package by means of LoadFromSqlServer method how to read its Sql Tasks, for example?

I'm trying with the Executables property but unsuccessfully results:

pkg.Executables.Item(0)

Thanks in advance,

Do you receive an error message?

Have you read http://msdn2.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.package.executables.aspx|||

No, not all.

I think that I wrote my post a little bit confused. I meant, how to see/read the properties for a Sql Task, as SqlStatement, Sqlsourcetype...

I receive this:

{Microsoft.SqlServer.Dts.Runtime.Sequence}

Microsoft.SqlServer.Dts.Runtime.Sequence: {Microsoft.SqlServer.Dts.Runtime.Sequence}

Thanks again,

|||

hi guys,

Any idea?

|||SSIS package traversal Examples (in C#) are available in Microsoft's BI Metadata Samples download.

Also, try out Windows PowerShell. It's essentially a .NET object shell with the ability to perform real-time Intellisense on objects (such a SSIS package objects).

The following lists the package's top level Executables' properties. Its very minimalistic, but create a package with an Execute SQL tasks at the package level; then execute the below against the package.
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.ManagedDTS") > $null;
$app = new-object Microsoft.SqlServer.Dts.Runtime.Application;
$p = $app.LoadPackage("c:\sample.dtsx",$null)
$p.Executables


|||

No, I wanna make an application of mine.

It cannot so difficult as all of this.

|||

Does anyone have any idea?

Thanks again,

|||

Enric,

You'll want to cast the executable from the package's executable collection to Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ExecuteSQLTask, then you'll have access to the properties you are trying to set.

~Patrik

|||

I don't get the point. Could you please be more specific?

Thanks again,

|||

Below is a simple example which loads a package from the file system, finds the Execute Sql Task, changes one if its properties, and then gives options to persist the changes or execute the changed packaged.

More information about the SSIS object model and can be found at: http://msdn2.microsoft.com/en-us/library/ms137709.aspx

// using statements
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask;

// create in instance of Microsoft.SqlServer.Dts.Runtime.Application
Application app = newApplication();

// load an existing package
Package pkg = app.LoadPackage(@."C:\TestPackage.dtsx", null);

// find Execute Sql Task
ExecuteSQLTask task = null;

foreach (Executable exe in pkg.Executables)
{
// the package in this example only has one Execute Sql Task so this
// is sufficient to find the task, otherwise base your find on the unique name
// given to the task
TaskHost tmpTaskHost = (TaskHost)exe;
if (tmpTaskHost.InnerObject isExecuteSQLTask)
{
task = tmpTaskHost.InnerObject asExecuteSQLTask;
break;
}
}

// update the task's properties
if (task != null)
{
task.SqlStatementSource = "select * from tbl";
}

// if you want to save the changes
// app.SaveToXml("newPackage.dtsx", pkg, null);

// if you want to execute the package
// DTSExecResult result = pkg.Execute();

Hope this helps,
Patrik

|||

Thanks a lot for that.

|||

humm. Not very useful for my plan..

If I've got a SSIS which owns 30 different tasks I'll have 30 assemblies..

Microsoft.SqlServer.SQLTask.dll.. for Sql Task

Microsoft.SqlServer.SendMailTask.dll for Send Mail Task

..

..

|||

Enric,

That's true.

Something that we haven't gotten to in this thread is what you are trying to accomplish. Can you fill us in on what you're hoping to do. Maybe there's another direction we could help you with.

Cheers,
Patrik

|||

Our goal is just to obtain the metadata for each SSIS. Now, we've got only ten SSIS but in a future there will be a lot of them running.

Thanks.

How to read sql tasks and so on from a package programmatically?

Hi everyone,

Once I've accesed to package by means of LoadFromSqlServer method how to read its Sql Tasks, for example?

I'm trying with the Executables property but unsuccessfully results:

pkg.Executables.Item(0)

Thanks in advance,

Do you receive an error message?

Have you read http://msdn2.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.package.executables.aspx|||

No, not all.

I think that I wrote my post a little bit confused. I meant, how to see/read the properties for a Sql Task, as SqlStatement, Sqlsourcetype...

I receive this:

{Microsoft.SqlServer.Dts.Runtime.Sequence}

Microsoft.SqlServer.Dts.Runtime.Sequence: {Microsoft.SqlServer.Dts.Runtime.Sequence}

Thanks again,

|||

hi guys,

Any idea?

|||SSIS package traversal Examples (in C#) are available in Microsoft's BI Metadata Samples download.

Also, try out Windows PowerShell. It's essentially a .NET object shell with

the ability to perform real-time Intellisense on objects (such a SSIS

package objects).

The following lists the package's top level Executables' properties. Its very minimalistic, but create a package with an Execute SQL tasks at the package level; then execute the below against the package.

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.ManagedDTS") > $null;

$app = new-object Microsoft.SqlServer.Dts.Runtime.Application;

$p = $app.LoadPackage("c:\sample.dtsx",$null)

$p.Executables


|||

No, I wanna make an application of mine.

It cannot so difficult as all of this.

|||

Does anyone have any idea?

Thanks again,

|||

Enric,

You'll want to cast the executable from the package's executable collection to Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ExecuteSQLTask, then you'll have access to the properties you are trying to set.

~Patrik

|||

I don't get the point. Could you please be more specific?

Thanks again,

|||

Below is a simple example which loads a package from the file system, finds the Execute Sql Task, changes one if its properties, and then gives options to persist the changes or execute the changed packaged.

More information about the SSIS object model and can be found at: http://msdn2.microsoft.com/en-us/library/ms137709.aspx

// using statements
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask;

// create in instance of Microsoft.SqlServer.Dts.Runtime.Application
Application app = new Application();

// load an existing package
Package pkg = app.LoadPackage(@."C:\TestPackage.dtsx", null);

// find Execute Sql Task
ExecuteSQLTask task = null;

foreach (Executable exe in pkg.Executables)
{
// the package in this example only has one Execute Sql Task so this
// is sufficient to find the task, otherwise base your find on the unique name
// given to the task
TaskHost tmpTaskHost = (TaskHost)exe;
if (tmpTaskHost.InnerObject is ExecuteSQLTask)
{
task = tmpTaskHost.InnerObject as ExecuteSQLTask;
break;
}
}

// update the task's properties
if (task != null)
{
task.SqlStatementSource = "select * from tbl";
}

// if you want to save the changes
// app.SaveToXml("newPackage.dtsx", pkg, null);

// if you want to execute the package
// DTSExecResult result = pkg.Execute();

Hope this helps,
Patrik

|||

Thanks a lot for that.

|||

humm. Not very useful for my plan..

If I've got a SSIS which owns 30 different tasks I'll have 30 assemblies..

Microsoft.SqlServer.SQLTask.dll.. for Sql Task

Microsoft.SqlServer.SendMailTask.dll for Send Mail Task

..

..

|||

Enric,

That's true.

Something that we haven't gotten to in this thread is what you are trying to accomplish. Can you fill us in on what you're hoping to do. Maybe there's another direction we could help you with.

Cheers,
Patrik

|||

Our goal is just to obtain the metadata for each SSIS. Now, we've got only ten SSIS but in a future there will be a lot of them running.

Thanks.

How to read sql tasks and so on from a package programmatically?

Hi everyone,

Once I've accesed to package by means of LoadFromSqlServer method how to read its Sql Tasks, for example?

I'm trying with the Executables property but unsuccessfully results:

pkg.Executables.Item(0)

Thanks in advance,

Do you receive an error message?

Have you read http://msdn2.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.package.executables.aspx|||

No, not all.

I think that I wrote my post a little bit confused. I meant, how to see/read the properties for a Sql Task, as SqlStatement, Sqlsourcetype...

I receive this:

{Microsoft.SqlServer.Dts.Runtime.Sequence}

Microsoft.SqlServer.Dts.Runtime.Sequence: {Microsoft.SqlServer.Dts.Runtime.Sequence}

Thanks again,

|||

hi guys,

Any idea?

|||SSIS package traversal Examples (in C#) are available in Microsoft's BI Metadata Samples download.

Also, try out Windows PowerShell. It's essentially a .NET object shell with

the ability to perform real-time Intellisense on objects (such a SSIS

package objects).

The following lists the package's top level Executables' properties. Its very minimalistic, but create a package with an Execute SQL tasks at the package level; then execute the below against the package.

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.ManagedDTS") > $null;

$app = new-object Microsoft.SqlServer.Dts.Runtime.Application;

$p = $app.LoadPackage("c:\sample.dtsx",$null)

$p.Executables


|||

No, I wanna make an application of mine.

It cannot so difficult as all of this.

|||

Does anyone have any idea?

Thanks again,

|||

Enric,

You'll want to cast the executable from the package's executable collection to Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ExecuteSQLTask, then you'll have access to the properties you are trying to set.

~Patrik

|||

I don't get the point. Could you please be more specific?

Thanks again,

|||

Below is a simple example which loads a package from the file system, finds the Execute Sql Task, changes one if its properties, and then gives options to persist the changes or execute the changed packaged.

More information about the SSIS object model and can be found at: http://msdn2.microsoft.com/en-us/library/ms137709.aspx

// using statements
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask;

// create in instance of Microsoft.SqlServer.Dts.Runtime.Application
Application app = new Application();

// load an existing package
Package pkg = app.LoadPackage(@."C:\TestPackage.dtsx", null);

// find Execute Sql Task
ExecuteSQLTask task = null;

foreach (Executable exe in pkg.Executables)
{
// the package in this example only has one Execute Sql Task so this
// is sufficient to find the task, otherwise base your find on the unique name
// given to the task
TaskHost tmpTaskHost = (TaskHost)exe;
if (tmpTaskHost.InnerObject is ExecuteSQLTask)
{
task = tmpTaskHost.InnerObject as ExecuteSQLTask;
break;
}
}

// update the task's properties
if (task != null)
{
task.SqlStatementSource = "select * from tbl";
}

// if you want to save the changes
// app.SaveToXml("newPackage.dtsx", pkg, null);

// if you want to execute the package
// DTSExecResult result = pkg.Execute();

Hope this helps,
Patrik

|||

Thanks a lot for that.

|||

humm. Not very useful for my plan..

If I've got a SSIS which owns 30 different tasks I'll have 30 assemblies..

Microsoft.SqlServer.SQLTask.dll.. for Sql Task

Microsoft.SqlServer.SendMailTask.dll for Send Mail Task

..

..

|||

Enric,

That's true.

Something that we haven't gotten to in this thread is what you are trying to accomplish. Can you fill us in on what you're hoping to do. Maybe there's another direction we could help you with.

Cheers,
Patrik

|||

Our goal is just to obtain the metadata for each SSIS. Now, we've got only ten SSIS but in a future there will be a lot of them running.

Thanks.

How to read parent Package in Script Task

Hi,
In SQL2000 DTS, I set a variable to DTSGlobalVariables.Parent. Then I can manipulate the package.
What is the equivalent way in SQL 2005 SSIS?
Thanks for all the help!
TTSQL Server 2005 Integration Services has no exact eqivalent. However, you can use package configurations and property expressions to accomplish the task that you describe. I especially recommend that you take a look at the Parent package variable configuration type.
Books Online includes a number of topics about package configurations and property expressions. You might find the following topics useful:
Package Configurations
Creating Package Configurations
Using Property Expressions in Packages
dtexec Utility
Configuration Class

Marianne
SQL Server User Education

This posting is provided "AS IS" with no warranties, and confers no rights.

|||Still - how can I read "Description" property of the current package in the "Script Task"?|||

In addition to Marianne's reply, check out this article for more information regarding the "DTSGlobalVariables.Parent" equivalent in SSIS.

http://blogs.conchango.com/jamiethomson/archive/2005/02/28/SSIS_3A00_-Dynamic-modification-of-SSIS-packages.aspx

How to read parent Package in Script Task

Hi,
In SQL2000 DTS, I set a variable to DTSGlobalVariables.Parent. Then I can manipulate the package.
What is the equivalent way in SQL 2005 SSIS?
Thanks for all the help!
TT
SQL Server 2005 Integration Services has no exact eqivalent. However, you can use package configurations and property expressions to accomplish the task that you describe. I especially recommend that you take a look at the Parent package variable configuration type.
Books Online includes a number of topics about package configurations and property expressions. You might find the following topics useful:
Package Configurations
Creating Package Configurations
Using Property Expressions in Packages
dtexec Utility
Configuration Class

Marianne
SQL Server User Education

This posting is provided "AS IS" with no warranties, and confers no rights.

|||Still - how can I read "Description" property of the current package in the "Script Task"?|||

In addition to Marianne's reply, check out this article for more information regarding the "DTSGlobalVariables.Parent" equivalent in SSIS.

http://blogs.conchango.com/jamiethomson/archive/2005/02/28/SSIS_3A00_-Dynamic-modification-of-SSIS-packages.aspx

How to read parent Package in Script Task

Hi,
In SQL2000 DTS, I set a variable to DTSGlobalVariables.Parent. Then I can manipulate the package.
What is the equivalent way in SQL 2005 SSIS?
Thanks for all the help!
TT
SQL Server 2005 Integration Services has no exact eqivalent. However, you can use package configurations and property expressions to accomplish the task that you describe. I especially recommend that you take a look at the Parent package variable configuration type.
Books Online includes a number of topics about package configurations and property expressions. You might find the following topics useful:
Package Configurations
Creating Package Configurations
Using Property Expressions in Packages
dtexec Utility
Configuration Class

Marianne
SQL Server User Education

This posting is provided "AS IS" with no warranties, and confers no rights.

|||Still - how can I read "Description" property of the current package in the "Script Task"?|||

In addition to Marianne's reply, check out this article for more information regarding the "DTSGlobalVariables.Parent" equivalent in SSIS.

http://blogs.conchango.com/jamiethomson/archive/2005/02/28/SSIS_3A00_-Dynamic-modification-of-SSIS-packages.aspx

Wednesday, March 7, 2012

How to read a package variable in a custom component?

What I tried, based on something I found in Jamies blog:

IDTSVariables90 vars = null;
this.VariableDispenser.GetVariables(out vars);

However the vars stays empty, while I have 3 user variables defined. I saw in the documentation that one should not use 'VariableDispenser' since it is for internal use. But is there a better way, like in a script task, you just do
Dts.Variables("BatchID") .

Youre input is appreciated,
HenkPlease note the additional comments in the BOL topic on the Variable Dispenser property of the PipelineComponent base class. (The HTML always suffers when being copied and pasted, see below.) Can you try locking the variable first?
--

Remarks

The VariableDispenser is used to read and write variables in the package that contains the component. Before reading or writing a variable, it must be locked using one of the following methods; LockForRead, LockForWrite, LockOneForRead, or LockOneForWrite. After the variables are locked using the dispenser, they are available through the IDTSVariables90 interface.


Example

The following example demonstrates how to use the VariableDispenser to lock a single variable, and multiple variables.

C# Copy Code // Lock two variables, and then retrieve them by calling GetVariables. IDTSVariables90 variables = null; VariableDispenser.LockForRead("variable1"); VariableDispenser.LockForRead("variable2"); VariableDispenser.GetVariables(ref variables); object variable1 = variables[0].Value; object variable2 = variables[1].Value; // Retrieve a single variable. IDTSVariables90 variables = null; VariableDispenser.LockOneForRead("variable1", ref variables); object variable1 = variables[0].Value;

|||Thanks Douglas!

How to read a .PST file from a SSIS package?

Hi everyone,

I'd like to read a .PST file (which contains thousands of mails) regardless of Exchange client.

Is it possible?

Thanks for your input

SSIS doesn't have an out-of-the-box component to do just that. If there's an OLE DB, .NET or ODBC provider for that data source, you can try that (I'm not sure there is one, but it's amazing to see the wealth of connectors out there for surprising data sources, you might want to check that).

Perhaps, another way could be exporting .PST file into some format SSIS can consume (i.e. flat file or xml) and get the data into SSIS that way.

And of course, you can always write your own component and plug it in SSIS.

|||Thanks for that.