Showing posts with label production. Show all posts
Showing posts with label production. Show all posts

Friday, March 9, 2012

Detach and Attach functions in SQL Server 2005

Hi,

I'm trying to port my ASP.NET web application to the production system.

I'm connection to the SQL Server 2005 instance on my hosting server via CTP. I've uploaded the .mdf and .ldf files of my DB via FTP to the hosting server, and then tried to attach using this command:

use master gosp_attach_db'tgp','F:\webspace\disk20\db\TGP.mdf','F:\webspace\disk20\db\TGP_log.ldf' go

but then there is an error (obviously) stating that I don't have permissions to create a database in database master.

I must admit that I'm prettycluelessin this area. My hostingservicesalready created a "place holder" for my database (tgp), but I don't know how to proceed from here in order attach the database files in the production environment. Is this something I can do myself, or must I involve the hosting services?

Thanks,

Alon

sp_attach_db requires the same permissions as CREATE DATABASE - so you're likely not going to be able to do this (if so, let me know who your host is - I could use the free/extra space they'd let me set up *grin*).

You'll either need to contact them and have them hook up your DB, or look into using user-instance/attachable SQL Express functionality.|||

You have two options just backup your database and use management studio to restore your database on the host SQL Server after you have registered the host SQL Server in your management studio. In the backup and restore wizard choose the restore from device option. The other option is try the thread below for Attach database code modify it for your needs and use it. Hope this helps.

http://forums.asp.net/thread/981274.aspx

|||

Thak you for your reply.

I tried to backup/restore, but when I tried to point to the location of the backup file (on the remote server), got the error message that I'm not authorized... I've just sent a request from the hosting firm to handle this.

I have a general question: what are the guidelines when moving from the test/development system to the production system? I couldn't find any article summarizing the process.

Thank you,

Alon

|||You should only use a company that gives you access to management studio so you can use the backup and restore wizard because if you don't backup your database they will charge you to back it up. Here in the US most hosting company will give you the access. Hope this helps.|||

Yep, this helpsSmile [:)]

Alon

Saturday, February 25, 2012

Designin and Processing Cubes

Does anyone have any best practices for processing cubes on a prod environment? If we have 1 server which we have the production cube on, what is the best way to get the changes into the production cube. I tried a backup and restore of the AS DB with no success. Should I just create the database on a dev server and keep prod and dev separate? Any assistance would HELP BIG TIME!!!

The ultimately the question is: what configuraion you can afford to have. The better practice many Analysis Services users have found is to have 2 servers: Staging and Production. You were to maintatain your production server for users to query and during late night you'd use Sychronization feature of Analysis Services to push a new state from the Staging server. On the Staging server you process updates into your dimensions and partitions, you do your backups and test whether the data is correct, you test your security in short you make sure you get your cubes ready before user can see them.

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

Friday, February 24, 2012

design questions

So, I don't have the most design experience... but thats about to change. Ive
got a DB that isn't in even 1st NF and has been in Production for some time.
There are hundreds of Stored Procs already and nobody is about to start
re-writing them. So, Im thinking I need to make use of Views. In this way,
existing SP's can stay the same, new SP's can be written against the new
table structures. Im sure Im not the first one to do this, so, any gotcha's?
Anything I need to have in my mind while I do the redesign so I don't spin my
wheels in the wrong direction and find this approach won't work?
TIA,
ChrisR
Chris,

> There are hundreds of Stored Procs already and nobody is about to start
> re-writing them. So, Im thinking I need to make use of Views. In this way,
> existing SP's can stay the same, new SP's can be written against the new
> table structures.
Obviously the best scenario would be a redesign to comply with 3rd NF
however it sounds like that is not going to happen. You already have an
abstraction layer to the underlying tables with stored procedures. Why do
you want to use views as well? I'm not saying that views should or should
not be used just trying to better understand your situation.
HTH
Jerry
"ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
news:6A3B81BB-2AE0-44BD-8BED-09D1F88E1398@.microsoft.com...
> So, I don't have the most design experience... but thats about to change.
> Ive
> got a DB that isn't in even 1st NF and has been in Production for some
> time.
> There are hundreds of Stored Procs already and nobody is about to start
> re-writing them. So, Im thinking I need to make use of Views. In this way,
> existing SP's can stay the same, new SP's can be written against the new
> table structures. Im sure Im not the first one to do this, so, any
> gotcha's?
> Anything I need to have in my mind while I do the redesign so I don't spin
> my
> wheels in the wrong direction and find this approach won't work?
> --
> TIA,
> ChrisR
|||Depends what you mean by "not in 1NF". If you intend to declare new keys and
constraints then views alone won't stop the legacy code throwing constraint
violation errors. Also, not every view may be updateable.
Triggers on INSTEAD OF views might be an option but you might find that it's
easier to rewrite the procs rather than try to accommodate every one of them
in a trigger.
David Portas
SQL Server MVP
"ChrisR" wrote:

> So, I don't have the most design experience... but thats about to change. Ive
> got a DB that isn't in even 1st NF and has been in Production for some time.
> There are hundreds of Stored Procs already and nobody is about to start
> re-writing them. So, Im thinking I need to make use of Views. In this way,
> existing SP's can stay the same, new SP's can be written against the new
> table structures. Im sure Im not the first one to do this, so, any gotcha's?
> Anything I need to have in my mind while I do the redesign so I don't spin my
> wheels in the wrong direction and find this approach won't work?
> --
> TIA,
> ChrisR
|||The use of Views would be this:
Lets say we have a table called "Client":
ClientID
LName
FName
Address
Address2
City
City2
State
State2
Child1
Child2
Child3
Child4
Child5
This doesn't look too far some of the tables we have. An option would be to
Rename Client to ClientTable with only 3 columns.
ClientID
LName
FName
Another table named ClientAddress. (More than 1 address can be entered here
if needed.)
ClientID
Address
City
State
And another table called ClientChildMore than 1 child can be entered here
if needed.)
ClientID
Child
And finally, create a view named Client.
Create View Client
as
select * from ClientTable ct
inner join ClientAddress ca on ct.ClientId = ca.ClientId
inner join ClientChild cc on ct.ClientId = cc.ClientID
This is a tactic I've heard used by others, but never done it myself.
TIA,
ChrisR
"ChrisR" wrote:

> So, I don't have the most design experience... but thats about to change. Ive
> got a DB that isn't in even 1st NF and has been in Production for some time.
> There are hundreds of Stored Procs already and nobody is about to start
> re-writing them. So, Im thinking I need to make use of Views. In this way,
> existing SP's can stay the same, new SP's can be written against the new
> table structures. Im sure Im not the first one to do this, so, any gotcha's?
> Anything I need to have in my mind while I do the redesign so I don't spin my
> wheels in the wrong direction and find this approach won't work?
> --
> TIA,
> ChrisR
|||Chris,
I am working on a major redesign at the moment. My shop also has lots of SPs
and tightly-coupled JSP code. My plan is to redesign the database from
scratch and then refactor the database and its attendant code bit by bit so
that in a year or so we will have completely re-engineered to database. In
other words,
1. Design a new, target schema.
2. Map the old schema to the new schema.
3. Develop a plan to convert "table clusters" from the old to the new schema.
4. Follow the plan.
For example, you may have a "company cluster" that consists of several
tables that handle company information. Convert this cluster from the old
schema to the new schema and rewrite your code base to utilize the new schema.
HTH,
Mike

design questions

So, I don't have the most design experience... but thats about to change. Iv
e
got a DB that isn't in even 1st NF and has been in Production for some time.
There are hundreds of Stored Procs already and nobody is about to start
re-writing them. So, Im thinking I need to make use of Views. In this way,
existing SP's can stay the same, new SP's can be written against the new
table structures. Im sure Im not the first one to do this, so, any gotcha's?
Anything I need to have in my mind while I do the redesign so I don't spin m
y
wheels in the wrong direction and find this approach won't work?
TIA,
ChrisRChris,

> There are hundreds of Stored Procs already and nobody is about to start
> re-writing them. So, Im thinking I need to make use of Views. In this way,
> existing SP's can stay the same, new SP's can be written against the new
> table structures.
Obviously the best scenario would be a redesign to comply with 3rd NF
however it sounds like that is not going to happen. You already have an
abstraction layer to the underlying tables with stored procedures. Why do
you want to use views as well? I'm not saying that views should or should
not be used just trying to better understand your situation.
HTH
Jerry
"ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
news:6A3B81BB-2AE0-44BD-8BED-09D1F88E1398@.microsoft.com...
> So, I don't have the most design experience... but thats about to change.
> Ive
> got a DB that isn't in even 1st NF and has been in Production for some
> time.
> There are hundreds of Stored Procs already and nobody is about to start
> re-writing them. So, Im thinking I need to make use of Views. In this way,
> existing SP's can stay the same, new SP's can be written against the new
> table structures. Im sure Im not the first one to do this, so, any
> gotcha's?
> Anything I need to have in my mind while I do the redesign so I don't spin
> my
> wheels in the wrong direction and find this approach won't work?
> --
> TIA,
> ChrisR|||Depends what you mean by "not in 1NF". If you intend to declare new keys and
constraints then views alone won't stop the legacy code throwing constraint
violation errors. Also, not every view may be updateable.
Triggers on INSTEAD OF views might be an option but you might find that it's
easier to rewrite the procs rather than try to accommodate every one of them
in a trigger.
David Portas
SQL Server MVP
--
"ChrisR" wrote:

> So, I don't have the most design experience... but thats about to change.
Ive
> got a DB that isn't in even 1st NF and has been in Production for some tim
e.
> There are hundreds of Stored Procs already and nobody is about to start
> re-writing them. So, Im thinking I need to make use of Views. In this way,
> existing SP's can stay the same, new SP's can be written against the new
> table structures. Im sure Im not the first one to do this, so, any gotcha'
s?
> Anything I need to have in my mind while I do the redesign so I don't spin
my
> wheels in the wrong direction and find this approach won't work?
> --
> TIA,
> ChrisR|||The use of Views would be this:
Lets say we have a table called "Client":
ClientID
LName
FName
Address
Address2
City
City2
State
State2
Child1
Child2
Child3
Child4
Child5
This doesn't look too far some of the tables we have. An option would be to
Rename Client to ClientTable with only 3 columns.
ClientID
LName
FName
Another table named ClientAddress. (More than 1 address can be entered here
if needed.)
ClientID
Address
City
State
And another table called ClientChildMore than 1 child can be entered here
if needed.)
ClientID
Child
And finally, create a view named Client.
Create View Client
as
select * from ClientTable ct
inner join ClientAddress ca on ct.ClientId = ca.ClientId
inner join ClientChild cc on ct.ClientId = cc.ClientID
This is a tactic I've heard used by others, but never done it myself.
TIA,
ChrisR
"ChrisR" wrote:

> So, I don't have the most design experience... but thats about to change.
Ive
> got a DB that isn't in even 1st NF and has been in Production for some tim
e.
> There are hundreds of Stored Procs already and nobody is about to start
> re-writing them. So, Im thinking I need to make use of Views. In this way,
> existing SP's can stay the same, new SP's can be written against the new
> table structures. Im sure Im not the first one to do this, so, any gotcha'
s?
> Anything I need to have in my mind while I do the redesign so I don't spin
my
> wheels in the wrong direction and find this approach won't work?
> --
> TIA,
> ChrisR|||Chris,
I am working on a major redesign at the moment. My shop also has lots of SPs
and tightly-coupled JSP code. My plan is to redesign the database from
scratch and then refactor the database and its attendant code bit by bit so
that in a year or so we will have completely re-engineered to database. In
other words,
1. Design a new, target schema.
2. Map the old schema to the new schema.
3. Develop a plan to convert "table clusters" from the old to the new schema
.
4. Follow the plan.
For example, you may have a "company cluster" that consists of several
tables that handle company information. Convert this cluster from the old
schema to the new schema and rewrite your code base to utilize the new schem
a.
HTH,
Mike

design questions

So, I don't have the most design experience... but thats about to change. Ive
got a DB that isn't in even 1st NF and has been in Production for some time.
There are hundreds of Stored Procs already and nobody is about to start
re-writing them. So, Im thinking I need to make use of Views. In this way,
existing SP's can stay the same, new SP's can be written against the new
table structures. Im sure Im not the first one to do this, so, any gotcha's?
Anything I need to have in my mind while I do the redesign so I don't spin my
wheels in the wrong direction and find this approach won't work?
--
TIA,
ChrisRChris,
> There are hundreds of Stored Procs already and nobody is about to start
> re-writing them. So, Im thinking I need to make use of Views. In this way,
> existing SP's can stay the same, new SP's can be written against the new
> table structures.
Obviously the best scenario would be a redesign to comply with 3rd NF
however it sounds like that is not going to happen. You already have an
abstraction layer to the underlying tables with stored procedures. Why do
you want to use views as well? I'm not saying that views should or should
not be used just trying to better understand your situation.
HTH
Jerry
"ChrisR" <ChrisR@.discussions.microsoft.com> wrote in message
news:6A3B81BB-2AE0-44BD-8BED-09D1F88E1398@.microsoft.com...
> So, I don't have the most design experience... but thats about to change.
> Ive
> got a DB that isn't in even 1st NF and has been in Production for some
> time.
> There are hundreds of Stored Procs already and nobody is about to start
> re-writing them. So, Im thinking I need to make use of Views. In this way,
> existing SP's can stay the same, new SP's can be written against the new
> table structures. Im sure Im not the first one to do this, so, any
> gotcha's?
> Anything I need to have in my mind while I do the redesign so I don't spin
> my
> wheels in the wrong direction and find this approach won't work?
> --
> TIA,
> ChrisR|||Depends what you mean by "not in 1NF". If you intend to declare new keys and
constraints then views alone won't stop the legacy code throwing constraint
violation errors. Also, not every view may be updateable.
Triggers on INSTEAD OF views might be an option but you might find that it's
easier to rewrite the procs rather than try to accommodate every one of them
in a trigger.
--
David Portas
SQL Server MVP
--
"ChrisR" wrote:
> So, I don't have the most design experience... but thats about to change. Ive
> got a DB that isn't in even 1st NF and has been in Production for some time.
> There are hundreds of Stored Procs already and nobody is about to start
> re-writing them. So, Im thinking I need to make use of Views. In this way,
> existing SP's can stay the same, new SP's can be written against the new
> table structures. Im sure Im not the first one to do this, so, any gotcha's?
> Anything I need to have in my mind while I do the redesign so I don't spin my
> wheels in the wrong direction and find this approach won't work?
> --
> TIA,
> ChrisR|||The use of Views would be this:
Lets say we have a table called "Client":
ClientID
LName
FName
Address
Address2
City
City2
State
State2
Child1
Child2
Child3
Child4
Child5
This doesn't look too far some of the tables we have. An option would be to
Rename Client to ClientTable with only 3 columns.
ClientID
LName
FName
Another table named ClientAddress. (More than 1 address can be entered here
if needed.)
ClientID
Address
City
State
And another table called ClientChild:(More than 1 child can be entered here
if needed.)
ClientID
Child
And finally, create a view named Client.
Create View Client
as
select * from ClientTable ct
inner join ClientAddress ca on ct.ClientId = ca.ClientId
inner join ClientChild cc on ct.ClientId = cc.ClientID
This is a tactic I've heard used by others, but never done it myself.
--
TIA,
ChrisR
"ChrisR" wrote:
> So, I don't have the most design experience... but thats about to change. Ive
> got a DB that isn't in even 1st NF and has been in Production for some time.
> There are hundreds of Stored Procs already and nobody is about to start
> re-writing them. So, Im thinking I need to make use of Views. In this way,
> existing SP's can stay the same, new SP's can be written against the new
> table structures. Im sure Im not the first one to do this, so, any gotcha's?
> Anything I need to have in my mind while I do the redesign so I don't spin my
> wheels in the wrong direction and find this approach won't work?
> --
> TIA,
> ChrisR|||Chris,
I am working on a major redesign at the moment. My shop also has lots of SPs
and tightly-coupled JSP code. My plan is to redesign the database from
scratch and then refactor the database and its attendant code bit by bit so
that in a year or so we will have completely re-engineered to database. In
other words,
1. Design a new, target schema.
2. Map the old schema to the new schema.
3. Develop a plan to convert "table clusters" from the old to the new schema.
4. Follow the plan.
For example, you may have a "company cluster" that consists of several
tables that handle company information. Convert this cluster from the old
schema to the new schema and rewrite your code base to utilize the new schema.
HTH,
Mike

Design Question- Dynamic Configuration of Metadata in Dataflow

I have a design question that I'd like some input on. I am trying to archive data from an extremely large production database. The tables to be archived changes quite often. It is currently along the lines of 80-100 tables with the possibility (likelihood) to grow from there.

If at all possible, I'd like to avoid writing an individual dataflow transformation for each table. I know that SSIS does not offer the same capabilities to change the metadata at runtime as DTS. I am currently exploring the option of programmatically creating/modifying the packages through the .Net framework. (using this link as a guide: http://msdn2.microsoft.com/en-us/library/ms345167.aspx).

I have concerns about the performance of this approach and was wondering if anyone had any feedback, or has implemented something similar, or has any other ideas on a different way to accomplish the same thing.

Thanks so much for your help,

Jessica

JessicaElise wrote:

I have a design question that I'd like some input on. I am trying to archive data from an extremely large production database. The tables to be archived changes quite often. It is currently along the lines of 80-100 tables with the possibility (likelihood) to grow from there.

If at all possible, I'd like to avoid writing an individual dataflow transformation for each table. I know that SSIS does not offer the same capabilities to change the metadata at runtime as DTS. I am currently exploring the option of programmatically creating/modifying the packages through the .Net framework. (using this link as a guide: http://msdn2.microsoft.com/en-us/library/ms345167.aspx).

I have concerns about the performance of this approach and was wondering if anyone had any feedback, or has implemented something similar, or has any other ideas on a different way to accomplish the same thing.

Thanks so much for your help,

Jessica

Assuming that the package you build programatically is the same as the package that you build in the SSIS Designer then performance will be exactly the same. Generating the package using the API shouldn't take too long - depends how good a coder you are

To be honest alot of people have mentioned they are attempting this but nobody has reported that they have achieved it. But then again why would they? People come on here to report problems, not successes.

Does that help at all? Probbaly not!!

-Jamie

|||Programmatically creating packages for each table is the way to go unfortunately. Have a look at this link: http://www.ivolva.com/ssis_code_generator.html I haven't used it myself, but if it does what it says, it should be a big help in writing the code to dynamically generate packages.|||

Well I'm reporting a success, Jamie. I got it working in a very base, proof-of-concept form. I've only tested it for very small datasets though. We'll see what happens when I increase the load (and run it multi-threaded). But, in case this can be of any use to anyone else:

I created a custom component that will create the a dynamic package based on an inputted source table, destination table and package name (source and destination connection strings are currently hardcoded, but I'm going to change that as I develop the component). I've been successful in using this component to create the package and then using the "Execute Package Task" to execute the package that was just created. Chuck that into a ForEach Loop that goes through a recordset containing a DestinationTable, SourceTable, and PackageName and modifies the expressions of the component and it works. Smile

Here's the meat-and-potatoes of the Custom Component I created.

Code Snippet

using System;

using System.Collections.Generic;

using System.Text;

using Microsoft.SqlServer.Dts.Runtime;

using System.IO;

using System.Data;

using Microsoft.SqlServer.Dts.Pipeline;

using Microsoft.SqlServer.Dts.Pipeline.Wrapper ;

namespace DynamicDataTransfer

{

[

DtsTask(

DisplayName = "Dynamic Data Transfer Task",

Description = "Dynamic Data Transfer.",

UITypeName = "DynamicDataTransfer.DynamicDataTransferTaskUI, DynamicDataTransfer, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=xxxxxxxxxxxxxxxx"

)

]

public class DynamicDataTransfer : Task

{

private string SourceTableNameInternal = "";

public string SourceTableName

{

get

{

return this.SourceTableNameInternal;

}

set

{

this.SourceTableNameInternal = value;

}

}

private string PackageNameInternal = "";

public string PackageName

{

get

{

return this.PackageNameInternal;

}

set

{

this.PackageNameInternal = value;

}

}

private string DestinationTableNameInternal = "";

public string DestinationTableName

{

get

{

return this.DestinationTableNameInternal;

}

set

{

this.DestinationTableNameInternal = value;

}

}

/// <summary>

/// Executes the task

/// </summary>

public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)

{

try

{

Microsoft.SqlServer.Dts.Runtime.Application a = new Microsoft.SqlServer.Dts.Runtime.Application();

String SSISPackageFilePath;

SSISPackageFilePath = PackageNameInternal;

if (File.Exists(SSISPackageFilePath))

File.Delete(SSISPackageFilePath);

Package pkg = new Package();

MainPipe dataFlow;

ConnectionManager conMgrSource = pkg.Connections.Add("OLEDB");

ConnectionManager conMgrDestination = pkg.Connections.Add("OLEDB");

conMgrSource.Name = "OLEDBConnectionSource";

conMgrSource.ConnectionString = "Data Source=SOURCESERVER;Initial Catalog=SOURCEDB;Provider=SQLNCLI.1;Integrated Security=SSPI;Auto Translate=False;";

conMgrDestination.Name = "OLEDBConnectionDestination";

conMgrDestination.ConnectionString = "Data Source=DESTINATIONSERVER;Initial Catalog=DESTINATIONDB;Provider=SQLNCLI.1;Integrated Security=SSPI;Auto Translate=False;";

Executable exe = pkg.Executables.Add("DTS.Pipeline.1");

TaskHost th = exe as TaskHost;

th.Name = "DynamicDataFlowTask";

dataFlow = th.InnerObject as MainPipe;

IDTSComponentMetaDataCollection90 metadataCollection = dataFlow.ComponentMetaDataCollection;

IDTSComponentMetaData90 OLEDBSource = dataFlow.ComponentMetaDataCollection.New();

OLEDBSource.Name = "OLEDBSource";

OLEDBSource.ComponentClassID = "DTSAdapter.OLEDBSource.1";

IDTSComponentMetaData90 OLEDBDestination = dataFlow.ComponentMetaDataCollection.New();

OLEDBDestination.Name = "OLEDBDestination";

OLEDBDestination.ComponentClassID = "DTSAdapter.OLEDBDestination.1";

// Get the design time instance of the component.

CManagedComponentWrapper InstanceSource = OLEDBSource.Instantiate();

// Initialize the component

InstanceSource.ProvideComponentProperties();

// Specify the connection manager.

if (OLEDBSource.RuntimeConnectionCollection.Count > 0)

{

OLEDBSource.RuntimeConnectionCollection[0].ConnectionManager = DtsConvert.ToConnectionManager90(pkg.Connections["OLEDBConnectionSource"]);

OLEDBSource.RuntimeConnectionCollection[0].ConnectionManagerID = pkg.Connections["OLEDBConnectionSource"].ID;

}

InstanceSource.SetComponentProperty("OpenRowset", SourceTableNameInternal);

InstanceSource.SetComponentProperty("AccessMode", 0);

//reinitialize the component

InstanceSource.AcquireConnections(null);

InstanceSource.ReinitializeMetaData();

InstanceSource.ReleaseConnections();

// Get the design time instance of the component.

CManagedComponentWrapper InstanceDestination = OLEDBDestination.Instantiate();

// Initialize the component

InstanceDestination.ProvideComponentProperties();

// Specify the connection manager.

if (OLEDBDestination.RuntimeConnectionCollection.Count > 0)

{

OLEDBDestination.RuntimeConnectionCollection[0].ConnectionManager = DtsConvert.ToConnectionManager90(pkg.Connections["OLEDBConnectionDestination"]);

OLEDBDestination.RuntimeConnectionCollection[0].ConnectionManagerID = pkg.Connections["OLEDBConnectionDestination"].ID;

}

InstanceDestination.SetComponentProperty("OpenRowset", DestinationTableNameInternal);

InstanceDestination.SetComponentProperty("AccessMode", 0);

//reinitialize the component

InstanceDestination.AcquireConnections(null);

InstanceDestination.ReinitializeMetaData();

InstanceDestination.ReleaseConnections();

//map the columns

IDTSPath90 path = dataFlow.PathCollection.New();

path.AttachPathAndPropagateNotifications(OLEDBSource.OutputCollection[0], OLEDBDestination.InputCollection[0]);

IDTSInput90 input = OLEDBDestination.InputCollection[0];

IDTSVirtualInput90 vInput = input.GetVirtualInput();

foreach (IDTSVirtualInputColumn90 vColumn in vInput.VirtualInputColumnCollection)

{

IDTSInputColumn90 vCol = InstanceDestination.SetUsageType(input.ID, vInput, vColumn.LineageID, DTSUsageType.UT_READWRITE);

InstanceDestination.MapInputColumn(input.ID, vCol.ID, input.ExternalMetadataColumnCollection[vColumn.Name].ID);

}

a.SaveToXml(SSISPackageFilePath, pkg, null);

th = null;

pkg = null;

a = null;

OLEDBSource = null;

OLEDBDestination = null;

InstanceSource = null;

InstanceDestination = null;

return DTSExecResult.Success;

}

catch (Exception exc)

{

componentEvents.FireError(0, "DynamicDataTransfer.Execute", "Task Errored: " + exc.ToString(), "", -1);

return DTSExecResult.Failure;

}

}

}

}

(Just as a side-note, your blog has helped me a ton since I've started with SSIS. Thanks for posting all of your findings.)

Jess

|||

Hey Jess,

I'm impressed. This is the first time I've seen a working bit of code that does this. Do you mind if I put a link from my blog to this? I think this needs to be shared.

One thing, the correct nomenclature is a custom task, not a custom component. My god, I must be in a critical mood

Regards

-Jamie

|||Custom Task, got it. Sure thing, link to your blog, I'll be proud. Smile|||

JessicaElise wrote:

Custom Task, got it. Sure thing, link to your blog, I'll be proud.

Cool. Done!

Building Packages Programatically

http://blogs.conchango.com/jamiethomson/archive/2007/03/28/SSIS_3A00_-Building-Packages-Programatically.aspx

Thanks again Jess.

-Jamie

|||

Hi Jamie,

Since the Script task only support VB.NET, I'd like to know how the above code can be deployed in our SSIS Package

Are there any conversion tool available?

|||

Subhash512525 wrote:

Hi Jamie,

Since the Script task only support VB.NET, I'd like to know how the above code can be deployed in our SSIS Package

Are there any conversion tool available?

Yes, I'm sure there is. Not being a .Net expert myself I don't know where to find them but I'm sure they exist.

-Jamie

|||

Thanks for your reply Jamie,

I was successful implementing the above code in VB.NET code with slight modifications and additions required for my package using online code converter available here . I must thank you both a lot for the code.

Subhash Subramanyam

|||

Jess,

I was directed to your post by John Welch. I have a need very similar to yours, however, I am not a developer and I am having difficulties implementing your code snippet. I have VS Express for C# loaded and when I create a class library project I get the following error:

The type or namespace name 'Dts' does not exist in the namespace 'Microsoft.SqlServer' (are you missing an assembly reference?)

Can someone point me in the right direction? What other code elements are needed to make this "meat and potatoes" portion work?

Thanks in advance,

Keith

|||

Hi ,

I am also facing this problem, but I didn't understand where I have to write this code. If it is in script task then where is the main() .Can you please tell me or reply on this email address.(ramanandap@.gmail.com).

Thanks in advance

|||

KC wrote:

Jess,

I was directed to your post by John Welch. I have a need very similar to yours, however, I am not a developer and I am having difficulties implementing your code snippet. I have VS Express for C# loaded and when I create a class library project I get the following error:

The type or namespace name 'Dts' does not exist in the namespace 'Microsoft.SqlServer' (are you missing an assembly reference?)

Can someone point me in the right direction? What other code elements are needed to make this "meat and potatoes" portion work?

Thanks in advance,

Keith

You need to add a reference to the Microsoft.SQLServer.DTSRuntimeWrap assembly to your project. Use Project..Add Reference.

|||

Mahi12345 wrote:

Hi ,

I am also facing this problem, but I didn't understand where I have to write this code. If it is in script task then where is the main() .Can you please tell me or reply on this email address.(ramanandap@.gmail.com).

Thanks in advance

This was created as a custom task in VB.NET. That gets compiled to a .NET assembly (DLL), registered in the GAC, and then can be used from your SSIS packages. If you look under "Developing Custom Tasks" in Books Online, you can see more information about this.

Design Question- Dynamic Configuration of Metadata in Dataflow

I have a design question that I'd like some input on. I am trying to archive data from an extremely large production database. The tables to be archived changes quite often. It is currently along the lines of 80-100 tables with the possibility (likelihood) to grow from there.

If at all possible, I'd like to avoid writing an individual dataflow transformation for each table. I know that SSIS does not offer the same capabilities to change the metadata at runtime as DTS. I am currently exploring the option of programmatically creating/modifying the packages through the .Net framework. (using this link as a guide: http://msdn2.microsoft.com/en-us/library/ms345167.aspx).

I have concerns about the performance of this approach and was wondering if anyone had any feedback, or has implemented something similar, or has any other ideas on a different way to accomplish the same thing.

Thanks so much for your help,

Jessica

JessicaElise wrote:

I have a design question that I'd like some input on. I am trying to archive data from an extremely large production database. The tables to be archived changes quite often. It is currently along the lines of 80-100 tables with the possibility (likelihood) to grow from there.

If at all possible, I'd like to avoid writing an individual dataflow transformation for each table. I know that SSIS does not offer the same capabilities to change the metadata at runtime as DTS. I am currently exploring the option of programmatically creating/modifying the packages through the .Net framework. (using this link as a guide: http://msdn2.microsoft.com/en-us/library/ms345167.aspx).

I have concerns about the performance of this approach and was wondering if anyone had any feedback, or has implemented something similar, or has any other ideas on a different way to accomplish the same thing.

Thanks so much for your help,

Jessica

Assuming that the package you build programatically is the same as the package that you build in the SSIS Designer then performance will be exactly the same. Generating the package using the API shouldn't take too long - depends how good a coder you are

To be honest alot of people have mentioned they are attempting this but nobody has reported that they have achieved it. But then again why would they? People come on here to report problems, not successes.

Does that help at all? Probbaly not!!

-Jamie

|||Programmatically creating packages for each table is the way to go unfortunately. Have a look at this link: http://www.ivolva.com/ssis_code_generator.html I haven't used it myself, but if it does what it says, it should be a big help in writing the code to dynamically generate packages.
|||

Well I'm reporting a success, Jamie. I got it working in a very base, proof-of-concept form. I've only tested it for very small datasets though. We'll see what happens when I increase the load (and run it multi-threaded). But, in case this can be of any use to anyone else:

I created a custom component that will create the a dynamic package based on an inputted source table, destination table and package name (source and destination connection strings are currently hardcoded, but I'm going to change that as I develop the component). I've been successful in using this component to create the package and then using the "Execute Package Task" to execute the package that was just created. Chuck that into a ForEach Loop that goes through a recordset containing a DestinationTable, SourceTable, and PackageName and modifies the expressions of the component and it works. Smile

Here's the meat-and-potatoes of the Custom Component I created.

Code Snippet

using System;

using System.Collections.Generic;

using System.Text;

using Microsoft.SqlServer.Dts.Runtime;

using System.IO;

using System.Data;

using Microsoft.SqlServer.Dts.Pipeline;

using Microsoft.SqlServer.Dts.Pipeline.Wrapper ;

namespace DynamicDataTransfer

{

[

DtsTask(

DisplayName = "Dynamic Data Transfer Task",

Description = "Dynamic Data Transfer.",

UITypeName = "DynamicDataTransfer.DynamicDataTransferTaskUI, DynamicDataTransfer, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=xxxxxxxxxxxxxxxx"

)

]

public class DynamicDataTransfer : Task

{

private string SourceTableNameInternal = "";

public string SourceTableName

{

get

{

return this.SourceTableNameInternal;

}

set

{

this.SourceTableNameInternal = value;

}

}

private string PackageNameInternal = "";

public string PackageName

{

get

{

return this.PackageNameInternal;

}

set

{

this.PackageNameInternal = value;

}

}

private string DestinationTableNameInternal = "";

public string DestinationTableName

{

get

{

return this.DestinationTableNameInternal;

}

set

{

this.DestinationTableNameInternal = value;

}

}

/// <summary>

/// Executes the task

/// </summary>

public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)

{

try

{

Microsoft.SqlServer.Dts.Runtime.Application a = new Microsoft.SqlServer.Dts.Runtime.Application();

String SSISPackageFilePath;

SSISPackageFilePath = PackageNameInternal;

if (File.Exists(SSISPackageFilePath))

File.Delete(SSISPackageFilePath);

Package pkg = new Package();

MainPipe dataFlow;

ConnectionManager conMgrSource = pkg.Connections.Add("OLEDB");

ConnectionManager conMgrDestination = pkg.Connections.Add("OLEDB");

conMgrSource.Name = "OLEDBConnectionSource";

conMgrSource.ConnectionString = "Data Source=SOURCESERVER;Initial Catalog=SOURCEDB;Provider=SQLNCLI.1;Integrated Security=SSPI;Auto Translate=False;";

conMgrDestination.Name = "OLEDBConnectionDestination";

conMgrDestination.ConnectionString = "Data Source=DESTINATIONSERVER;Initial Catalog=DESTINATIONDB;Provider=SQLNCLI.1;Integrated Security=SSPI;Auto Translate=False;";

Executable exe = pkg.Executables.Add("DTS.Pipeline.1");

TaskHost th = exe as TaskHost;

th.Name = "DynamicDataFlowTask";

dataFlow = th.InnerObject as MainPipe;

IDTSComponentMetaDataCollection90 metadataCollection = dataFlow.ComponentMetaDataCollection;

IDTSComponentMetaData90 OLEDBSource = dataFlow.ComponentMetaDataCollection.New();

OLEDBSource.Name = "OLEDBSource";

OLEDBSource.ComponentClassID = "DTSAdapter.OLEDBSource.1";

IDTSComponentMetaData90 OLEDBDestination = dataFlow.ComponentMetaDataCollection.New();

OLEDBDestination.Name = "OLEDBDestination";

OLEDBDestination.ComponentClassID = "DTSAdapter.OLEDBDestination.1";

// Get the design time instance of the component.

CManagedComponentWrapper InstanceSource = OLEDBSource.Instantiate();

// Initialize the component

InstanceSource.ProvideComponentProperties();

// Specify the connection manager.

if (OLEDBSource.RuntimeConnectionCollection.Count > 0)

{

OLEDBSource.RuntimeConnectionCollection[0].ConnectionManager = DtsConvert.ToConnectionManager90(pkg.Connections["OLEDBConnectionSource"]);

OLEDBSource.RuntimeConnectionCollection[0].ConnectionManagerID = pkg.Connections["OLEDBConnectionSource"].ID;

}

InstanceSource.SetComponentProperty("OpenRowset", SourceTableNameInternal);

InstanceSource.SetComponentProperty("AccessMode", 0);

//reinitialize the component

InstanceSource.AcquireConnections(null);

InstanceSource.ReinitializeMetaData();

InstanceSource.ReleaseConnections();

// Get the design time instance of the component.

CManagedComponentWrapper InstanceDestination = OLEDBDestination.Instantiate();

// Initialize the component

InstanceDestination.ProvideComponentProperties();

// Specify the connection manager.

if (OLEDBDestination.RuntimeConnectionCollection.Count > 0)

{

OLEDBDestination.RuntimeConnectionCollection[0].ConnectionManager = DtsConvert.ToConnectionManager90(pkg.Connections["OLEDBConnectionDestination"]);

OLEDBDestination.RuntimeConnectionCollection[0].ConnectionManagerID = pkg.Connections["OLEDBConnectionDestination"].ID;

}

InstanceDestination.SetComponentProperty("OpenRowset", DestinationTableNameInternal);

InstanceDestination.SetComponentProperty("AccessMode", 0);

//reinitialize the component

InstanceDestination.AcquireConnections(null);

InstanceDestination.ReinitializeMetaData();

InstanceDestination.ReleaseConnections();

//map the columns

IDTSPath90 path = dataFlow.PathCollection.New();

path.AttachPathAndPropagateNotifications(OLEDBSource.OutputCollection[0], OLEDBDestination.InputCollection[0]);

IDTSInput90 input = OLEDBDestination.InputCollection[0];

IDTSVirtualInput90 vInput = input.GetVirtualInput();

foreach (IDTSVirtualInputColumn90 vColumn in vInput.VirtualInputColumnCollection)

{

IDTSInputColumn90 vCol = InstanceDestination.SetUsageType(input.ID, vInput, vColumn.LineageID, DTSUsageType.UT_READWRITE);

InstanceDestination.MapInputColumn(input.ID, vCol.ID, input.ExternalMetadataColumnCollection[vColumn.Name].ID);

}

a.SaveToXml(SSISPackageFilePath, pkg, null);

th = null;

pkg = null;

a = null;

OLEDBSource = null;

OLEDBDestination = null;

InstanceSource = null;

InstanceDestination = null;

return DTSExecResult.Success;

}

catch (Exception exc)

{

componentEvents.FireError(0, "DynamicDataTransfer.Execute", "Task Errored: " + exc.ToString(), "", -1);

return DTSExecResult.Failure;

}

}

}

}

(Just as a side-note, your blog has helped me a ton since I've started with SSIS. Thanks for posting all of your findings.)

Jess

|||

Hey Jess,

I'm impressed. This is the first time I've seen a working bit of code that does this. Do you mind if I put a link from my blog to this? I think this needs to be shared.

One thing, the correct nomenclature is a custom task, not a custom component. My god, I must be in a critical mood

Regards

-Jamie

|||Custom Task, got it. Sure thing, link to your blog, I'll be proud. Smile|||

JessicaElise wrote:

Custom Task, got it. Sure thing, link to your blog, I'll be proud.

Cool. Done!

Building Packages Programatically

http://blogs.conchango.com/jamiethomson/archive/2007/03/28/SSIS_3A00_-Building-Packages-Programatically.aspx

Thanks again Jess.

-Jamie

|||

Hi Jamie,

Since the Script task only support VB.NET, I'd like to know how the above code can be deployed in our SSIS Package

Are there any conversion tool available?

|||

Subhash512525 wrote:

Hi Jamie,

Since the Script task only support VB.NET, I'd like to know how the above code can be deployed in our SSIS Package

Are there any conversion tool available?

Yes, I'm sure there is. Not being a .Net expert myself I don't know where to find them but I'm sure they exist.

-Jamie

|||

Thanks for your reply Jamie,

I was successful implementing the above code in VB.NET code with slight modifications and additions required for my package using online code converter available here . I must thank you both a lot for the code.

Subhash Subramanyam

|||

Jess,

I was directed to your post by John Welch. I have a need very similar to yours, however, I am not a developer and I am having difficulties implementing your code snippet. I have VS Express for C# loaded and when I create a class library project I get the following error:

The type or namespace name 'Dts' does not exist in the namespace 'Microsoft.SqlServer' (are you missing an assembly reference?)

Can someone point me in the right direction? What other code elements are needed to make this "meat and potatoes" portion work?

Thanks in advance,

Keith

|||

Hi ,

I am also facing this problem, but I didn't understand where I have to write this code. If it is in script task then where is the main() .Can you please tell me or reply on this email address.(ramanandap@.gmail.com).

Thanks in advance

|||

KC wrote:

Jess,

I was directed to your post by John Welch. I have a need very similar to yours, however, I am not a developer and I am having difficulties implementing your code snippet. I have VS Express for C# loaded and when I create a class library project I get the following error:

The type or namespace name 'Dts' does not exist in the namespace 'Microsoft.SqlServer' (are you missing an assembly reference?)

Can someone point me in the right direction? What other code elements are needed to make this "meat and potatoes" portion work?

Thanks in advance,

Keith

You need to add a reference to the Microsoft.SQLServer.DTSRuntimeWrap assembly to your project. Use Project..Add Reference.

|||

Mahi12345 wrote:

Hi ,

I am also facing this problem, but I didn't understand where I have to write this code. If it is in script task then where is the main() .Can you please tell me or reply on this email address.(ramanandap@.gmail.com).

Thanks in advance

This was created as a custom task in VB.NET. That gets compiled to a .NET assembly (DLL), registered in the GAC, and then can be used from your SSIS packages. If you look under "Developing Custom Tasks" in Books Online, you can see more information about this.

Design Question- Dynamic Configuration of Metadata in Dataflow

I have a design question that I'd like some input on. I am trying to archive data from an extremely large production database. The tables to be archived changes quite often. It is currently along the lines of 80-100 tables with the possibility (likelihood) to grow from there.

If at all possible, I'd like to avoid writing an individual dataflow transformation for each table. I know that SSIS does not offer the same capabilities to change the metadata at runtime as DTS. I am currently exploring the option of programmatically creating/modifying the packages through the .Net framework. (using this link as a guide: http://msdn2.microsoft.com/en-us/library/ms345167.aspx).

I have concerns about the performance of this approach and was wondering if anyone had any feedback, or has implemented something similar, or has any other ideas on a different way to accomplish the same thing.

Thanks so much for your help,

Jessica

JessicaElise wrote:

I have a design question that I'd like some input on. I am trying to archive data from an extremely large production database. The tables to be archived changes quite often. It is currently along the lines of 80-100 tables with the possibility (likelihood) to grow from there.

If at all possible, I'd like to avoid writing an individual dataflow transformation for each table. I know that SSIS does not offer the same capabilities to change the metadata at runtime as DTS. I am currently exploring the option of programmatically creating/modifying the packages through the .Net framework. (using this link as a guide: http://msdn2.microsoft.com/en-us/library/ms345167.aspx).

I have concerns about the performance of this approach and was wondering if anyone had any feedback, or has implemented something similar, or has any other ideas on a different way to accomplish the same thing.

Thanks so much for your help,

Jessica

Assuming that the package you build programatically is the same as the package that you build in the SSIS Designer then performance will be exactly the same. Generating the package using the API shouldn't take too long - depends how good a coder you are

To be honest alot of people have mentioned they are attempting this but nobody has reported that they have achieved it. But then again why would they? People come on here to report problems, not successes.

Does that help at all? Probbaly not!!

-Jamie

|||Programmatically creating packages for each table is the way to go unfortunately. Have a look at this link: http://www.ivolva.com/ssis_code_generator.html I haven't used it myself, but if it does what it says, it should be a big help in writing the code to dynamically generate packages.
|||

Well I'm reporting a success, Jamie. I got it working in a very base, proof-of-concept form. I've only tested it for very small datasets though. We'll see what happens when I increase the load (and run it multi-threaded). But, in case this can be of any use to anyone else:

I created a custom component that will create the a dynamic package based on an inputted source table, destination table and package name (source and destination connection strings are currently hardcoded, but I'm going to change that as I develop the component). I've been successful in using this component to create the package and then using the "Execute Package Task" to execute the package that was just created. Chuck that into a ForEach Loop that goes through a recordset containing a DestinationTable, SourceTable, and PackageName and modifies the expressions of the component and it works. Smile

Here's the meat-and-potatoes of the Custom Component I created.

Code Snippet

using System;

using System.Collections.Generic;

using System.Text;

using Microsoft.SqlServer.Dts.Runtime;

using System.IO;

using System.Data;

using Microsoft.SqlServer.Dts.Pipeline;

using Microsoft.SqlServer.Dts.Pipeline.Wrapper ;

namespace DynamicDataTransfer

{

[

DtsTask(

DisplayName = "Dynamic Data Transfer Task",

Description = "Dynamic Data Transfer.",

UITypeName = "DynamicDataTransfer.DynamicDataTransferTaskUI, DynamicDataTransfer, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=xxxxxxxxxxxxxxxx"

)

]

public class DynamicDataTransfer : Task

{

private string SourceTableNameInternal = "";

public string SourceTableName

{

get

{

return this.SourceTableNameInternal;

}

set

{

this.SourceTableNameInternal = value;

}

}

private string PackageNameInternal = "";

public string PackageName

{

get

{

return this.PackageNameInternal;

}

set

{

this.PackageNameInternal = value;

}

}

private string DestinationTableNameInternal = "";

public string DestinationTableName

{

get

{

return this.DestinationTableNameInternal;

}

set

{

this.DestinationTableNameInternal = value;

}

}

/// <summary>

/// Executes the task

/// </summary>

public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)

{

try

{

Microsoft.SqlServer.Dts.Runtime.Application a = new Microsoft.SqlServer.Dts.Runtime.Application();

String SSISPackageFilePath;

SSISPackageFilePath = PackageNameInternal;

if (File.Exists(SSISPackageFilePath))

File.Delete(SSISPackageFilePath);

Package pkg = new Package();

MainPipe dataFlow;

ConnectionManager conMgrSource = pkg.Connections.Add("OLEDB");

ConnectionManager conMgrDestination = pkg.Connections.Add("OLEDB");

conMgrSource.Name = "OLEDBConnectionSource";

conMgrSource.ConnectionString = "Data Source=SOURCESERVER;Initial Catalog=SOURCEDB;Provider=SQLNCLI.1;Integrated Security=SSPI;Auto Translate=False;";

conMgrDestination.Name = "OLEDBConnectionDestination";

conMgrDestination.ConnectionString = "Data Source=DESTINATIONSERVER;Initial Catalog=DESTINATIONDB;Provider=SQLNCLI.1;Integrated Security=SSPI;Auto Translate=False;";

Executable exe = pkg.Executables.Add("DTS.Pipeline.1");

TaskHost th = exe as TaskHost;

th.Name = "DynamicDataFlowTask";

dataFlow = th.InnerObject as MainPipe;

IDTSComponentMetaDataCollection90 metadataCollection = dataFlow.ComponentMetaDataCollection;

IDTSComponentMetaData90 OLEDBSource = dataFlow.ComponentMetaDataCollection.New();

OLEDBSource.Name = "OLEDBSource";

OLEDBSource.ComponentClassID = "DTSAdapter.OLEDBSource.1";

IDTSComponentMetaData90 OLEDBDestination = dataFlow.ComponentMetaDataCollection.New();

OLEDBDestination.Name = "OLEDBDestination";

OLEDBDestination.ComponentClassID = "DTSAdapter.OLEDBDestination.1";

// Get the design time instance of the component.

CManagedComponentWrapper InstanceSource = OLEDBSource.Instantiate();

// Initialize the component

InstanceSource.ProvideComponentProperties();

// Specify the connection manager.

if (OLEDBSource.RuntimeConnectionCollection.Count > 0)

{

OLEDBSource.RuntimeConnectionCollection[0].ConnectionManager = DtsConvert.ToConnectionManager90(pkg.Connections["OLEDBConnectionSource"]);

OLEDBSource.RuntimeConnectionCollection[0].ConnectionManagerID = pkg.Connections["OLEDBConnectionSource"].ID;

}

InstanceSource.SetComponentProperty("OpenRowset", SourceTableNameInternal);

InstanceSource.SetComponentProperty("AccessMode", 0);

//reinitialize the component

InstanceSource.AcquireConnections(null);

InstanceSource.ReinitializeMetaData();

InstanceSource.ReleaseConnections();

// Get the design time instance of the component.

CManagedComponentWrapper InstanceDestination = OLEDBDestination.Instantiate();

// Initialize the component

InstanceDestination.ProvideComponentProperties();

// Specify the connection manager.

if (OLEDBDestination.RuntimeConnectionCollection.Count > 0)

{

OLEDBDestination.RuntimeConnectionCollection[0].ConnectionManager = DtsConvert.ToConnectionManager90(pkg.Connections["OLEDBConnectionDestination"]);

OLEDBDestination.RuntimeConnectionCollection[0].ConnectionManagerID = pkg.Connections["OLEDBConnectionDestination"].ID;

}

InstanceDestination.SetComponentProperty("OpenRowset", DestinationTableNameInternal);

InstanceDestination.SetComponentProperty("AccessMode", 0);

//reinitialize the component

InstanceDestination.AcquireConnections(null);

InstanceDestination.ReinitializeMetaData();

InstanceDestination.ReleaseConnections();

//map the columns

IDTSPath90 path = dataFlow.PathCollection.New();

path.AttachPathAndPropagateNotifications(OLEDBSource.OutputCollection[0], OLEDBDestination.InputCollection[0]);

IDTSInput90 input = OLEDBDestination.InputCollection[0];

IDTSVirtualInput90 vInput = input.GetVirtualInput();

foreach (IDTSVirtualInputColumn90 vColumn in vInput.VirtualInputColumnCollection)

{

IDTSInputColumn90 vCol = InstanceDestination.SetUsageType(input.ID, vInput, vColumn.LineageID, DTSUsageType.UT_READWRITE);

InstanceDestination.MapInputColumn(input.ID, vCol.ID, input.ExternalMetadataColumnCollection[vColumn.Name].ID);

}

a.SaveToXml(SSISPackageFilePath, pkg, null);

th = null;

pkg = null;

a = null;

OLEDBSource = null;

OLEDBDestination = null;

InstanceSource = null;

InstanceDestination = null;

return DTSExecResult.Success;

}

catch (Exception exc)

{

componentEvents.FireError(0, "DynamicDataTransfer.Execute", "Task Errored: " + exc.ToString(), "", -1);

return DTSExecResult.Failure;

}

}

}

}

(Just as a side-note, your blog has helped me a ton since I've started with SSIS. Thanks for posting all of your findings.)

Jess

|||

Hey Jess,

I'm impressed. This is the first time I've seen a working bit of code that does this. Do you mind if I put a link from my blog to this? I think this needs to be shared.

One thing, the correct nomenclature is a custom task, not a custom component. My god, I must be in a critical mood

Regards

-Jamie

|||Custom Task, got it. Sure thing, link to your blog, I'll be proud. Smile|||

JessicaElise wrote:

Custom Task, got it. Sure thing, link to your blog, I'll be proud.

Cool. Done!

Building Packages Programatically

http://blogs.conchango.com/jamiethomson/archive/2007/03/28/SSIS_3A00_-Building-Packages-Programatically.aspx

Thanks again Jess.

-Jamie

|||

Hi Jamie,

Since the Script task only support VB.NET, I'd like to know how the above code can be deployed in our SSIS Package

Are there any conversion tool available?

|||

Subhash512525 wrote:

Hi Jamie,

Since the Script task only support VB.NET, I'd like to know how the above code can be deployed in our SSIS Package

Are there any conversion tool available?

Yes, I'm sure there is. Not being a .Net expert myself I don't know where to find them but I'm sure they exist.

-Jamie

|||

Thanks for your reply Jamie,

I was successful implementing the above code in VB.NET code with slight modifications and additions required for my package using online code converter available here . I must thank you both a lot for the code.

Subhash Subramanyam

|||

Jess,

I was directed to your post by John Welch. I have a need very similar to yours, however, I am not a developer and I am having difficulties implementing your code snippet. I have VS Express for C# loaded and when I create a class library project I get the following error:

The type or namespace name 'Dts' does not exist in the namespace 'Microsoft.SqlServer' (are you missing an assembly reference?)

Can someone point me in the right direction? What other code elements are needed to make this "meat and potatoes" portion work?

Thanks in advance,

Keith

|||

Hi ,

I am also facing this problem, but I didn't understand where I have to write this code. If it is in script task then where is the main() .Can you please tell me or reply on this email address.(ramanandap@.gmail.com).

Thanks in advance

|||

KC wrote:

Jess,

I was directed to your post by John Welch. I have a need very similar to yours, however, I am not a developer and I am having difficulties implementing your code snippet. I have VS Express for C# loaded and when I create a class library project I get the following error:

The type or namespace name 'Dts' does not exist in the namespace 'Microsoft.SqlServer' (are you missing an assembly reference?)

Can someone point me in the right direction? What other code elements are needed to make this "meat and potatoes" portion work?

Thanks in advance,

Keith

You need to add a reference to the Microsoft.SQLServer.DTSRuntimeWrap assembly to your project. Use Project..Add Reference.

|||

Mahi12345 wrote:

Hi ,

I am also facing this problem, but I didn't understand where I have to write this code. If it is in script task then where is the main() .Can you please tell me or reply on this email address.(ramanandap@.gmail.com).

Thanks in advance

This was created as a custom task in VB.NET. That gets compiled to a .NET assembly (DLL), registered in the GAC, and then can be used from your SSIS packages. If you look under "Developing Custom Tasks" in Books Online, you can see more information about this.

Design Question- Dynamic Configuration of Metadata in Dataflow

I have a design question that I'd like some input on. I am trying to archive data from an extremely large production database. The tables to be archived changes quite often. It is currently along the lines of 80-100 tables with the possibility (likelihood) to grow from there.

If at all possible, I'd like to avoid writing an individual dataflow transformation for each table. I know that SSIS does not offer the same capabilities to change the metadata at runtime as DTS. I am currently exploring the option of programmatically creating/modifying the packages through the .Net framework. (using this link as a guide: http://msdn2.microsoft.com/en-us/library/ms345167.aspx).

I have concerns about the performance of this approach and was wondering if anyone had any feedback, or has implemented something similar, or has any other ideas on a different way to accomplish the same thing.

Thanks so much for your help,

Jessica

JessicaElise wrote:

I have a design question that I'd like some input on. I am trying to archive data from an extremely large production database. The tables to be archived changes quite often. It is currently along the lines of 80-100 tables with the possibility (likelihood) to grow from there.

If at all possible, I'd like to avoid writing an individual dataflow transformation for each table. I know that SSIS does not offer the same capabilities to change the metadata at runtime as DTS. I am currently exploring the option of programmatically creating/modifying the packages through the .Net framework. (using this link as a guide: http://msdn2.microsoft.com/en-us/library/ms345167.aspx).

I have concerns about the performance of this approach and was wondering if anyone had any feedback, or has implemented something similar, or has any other ideas on a different way to accomplish the same thing.

Thanks so much for your help,

Jessica

Assuming that the package you build programatically is the same as the package that you build in the SSIS Designer then performance will be exactly the same. Generating the package using the API shouldn't take too long - depends how good a coder you are

To be honest alot of people have mentioned they are attempting this but nobody has reported that they have achieved it. But then again why would they? People come on here to report problems, not successes.

Does that help at all? Probbaly not!!

-Jamie

|||Programmatically creating packages for each table is the way to go unfortunately. Have a look at this link: http://www.ivolva.com/ssis_code_generator.html I haven't used it myself, but if it does what it says, it should be a big help in writing the code to dynamically generate packages.
|||

Well I'm reporting a success, Jamie. I got it working in a very base, proof-of-concept form. I've only tested it for very small datasets though. We'll see what happens when I increase the load (and run it multi-threaded). But, in case this can be of any use to anyone else:

I created a custom component that will create the a dynamic package based on an inputted source table, destination table and package name (source and destination connection strings are currently hardcoded, but I'm going to change that as I develop the component). I've been successful in using this component to create the package and then using the "Execute Package Task" to execute the package that was just created. Chuck that into a ForEach Loop that goes through a recordset containing a DestinationTable, SourceTable, and PackageName and modifies the expressions of the component and it works. Smile

Here's the meat-and-potatoes of the Custom Component I created.

Code Snippet

using System;

using System.Collections.Generic;

using System.Text;

using Microsoft.SqlServer.Dts.Runtime;

using System.IO;

using System.Data;

using Microsoft.SqlServer.Dts.Pipeline;

using Microsoft.SqlServer.Dts.Pipeline.Wrapper ;

namespace DynamicDataTransfer

{

[

DtsTask(

DisplayName = "Dynamic Data Transfer Task",

Description = "Dynamic Data Transfer.",

UITypeName = "DynamicDataTransfer.DynamicDataTransferTaskUI, DynamicDataTransfer, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=xxxxxxxxxxxxxxxx"

)

]

public class DynamicDataTransfer : Task

{

private string SourceTableNameInternal = "";

public string SourceTableName

{

get

{

return this.SourceTableNameInternal;

}

set

{

this.SourceTableNameInternal = value;

}

}

private string PackageNameInternal = "";

public string PackageName

{

get

{

return this.PackageNameInternal;

}

set

{

this.PackageNameInternal = value;

}

}

private string DestinationTableNameInternal = "";

public string DestinationTableName

{

get

{

return this.DestinationTableNameInternal;

}

set

{

this.DestinationTableNameInternal = value;

}

}

/// <summary>

/// Executes the task

/// </summary>

public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)

{

try

{

Microsoft.SqlServer.Dts.Runtime.Application a = new Microsoft.SqlServer.Dts.Runtime.Application();

String SSISPackageFilePath;

SSISPackageFilePath = PackageNameInternal;

if (File.Exists(SSISPackageFilePath))

File.Delete(SSISPackageFilePath);

Package pkg = new Package();

MainPipe dataFlow;

ConnectionManager conMgrSource = pkg.Connections.Add("OLEDB");

ConnectionManager conMgrDestination = pkg.Connections.Add("OLEDB");

conMgrSource.Name = "OLEDBConnectionSource";

conMgrSource.ConnectionString = "Data Source=SOURCESERVER;Initial Catalog=SOURCEDB;Provider=SQLNCLI.1;Integrated Security=SSPI;Auto Translate=False;";

conMgrDestination.Name = "OLEDBConnectionDestination";

conMgrDestination.ConnectionString = "Data Source=DESTINATIONSERVER;Initial Catalog=DESTINATIONDB;Provider=SQLNCLI.1;Integrated Security=SSPI;Auto Translate=False;";

Executable exe = pkg.Executables.Add("DTS.Pipeline.1");

TaskHost th = exe as TaskHost;

th.Name = "DynamicDataFlowTask";

dataFlow = th.InnerObject as MainPipe;

IDTSComponentMetaDataCollection90 metadataCollection = dataFlow.ComponentMetaDataCollection;

IDTSComponentMetaData90 OLEDBSource = dataFlow.ComponentMetaDataCollection.New();

OLEDBSource.Name = "OLEDBSource";

OLEDBSource.ComponentClassID = "DTSAdapter.OLEDBSource.1";

IDTSComponentMetaData90 OLEDBDestination = dataFlow.ComponentMetaDataCollection.New();

OLEDBDestination.Name = "OLEDBDestination";

OLEDBDestination.ComponentClassID = "DTSAdapter.OLEDBDestination.1";

// Get the design time instance of the component.

CManagedComponentWrapper InstanceSource = OLEDBSource.Instantiate();

// Initialize the component

InstanceSource.ProvideComponentProperties();

// Specify the connection manager.

if (OLEDBSource.RuntimeConnectionCollection.Count > 0)

{

OLEDBSource.RuntimeConnectionCollection[0].ConnectionManager = DtsConvert.ToConnectionManager90(pkg.Connections["OLEDBConnectionSource"]);

OLEDBSource.RuntimeConnectionCollection[0].ConnectionManagerID = pkg.Connections["OLEDBConnectionSource"].ID;

}

InstanceSource.SetComponentProperty("OpenRowset", SourceTableNameInternal);

InstanceSource.SetComponentProperty("AccessMode", 0);

//reinitialize the component

InstanceSource.AcquireConnections(null);

InstanceSource.ReinitializeMetaData();

InstanceSource.ReleaseConnections();

// Get the design time instance of the component.

CManagedComponentWrapper InstanceDestination = OLEDBDestination.Instantiate();

// Initialize the component

InstanceDestination.ProvideComponentProperties();

// Specify the connection manager.

if (OLEDBDestination.RuntimeConnectionCollection.Count > 0)

{

OLEDBDestination.RuntimeConnectionCollection[0].ConnectionManager = DtsConvert.ToConnectionManager90(pkg.Connections["OLEDBConnectionDestination"]);

OLEDBDestination.RuntimeConnectionCollection[0].ConnectionManagerID = pkg.Connections["OLEDBConnectionDestination"].ID;

}

InstanceDestination.SetComponentProperty("OpenRowset", DestinationTableNameInternal);

InstanceDestination.SetComponentProperty("AccessMode", 0);

//reinitialize the component

InstanceDestination.AcquireConnections(null);

InstanceDestination.ReinitializeMetaData();

InstanceDestination.ReleaseConnections();

//map the columns

IDTSPath90 path = dataFlow.PathCollection.New();

path.AttachPathAndPropagateNotifications(OLEDBSource.OutputCollection[0], OLEDBDestination.InputCollection[0]);

IDTSInput90 input = OLEDBDestination.InputCollection[0];

IDTSVirtualInput90 vInput = input.GetVirtualInput();

foreach (IDTSVirtualInputColumn90 vColumn in vInput.VirtualInputColumnCollection)

{

IDTSInputColumn90 vCol = InstanceDestination.SetUsageType(input.ID, vInput, vColumn.LineageID, DTSUsageType.UT_READWRITE);

InstanceDestination.MapInputColumn(input.ID, vCol.ID, input.ExternalMetadataColumnCollection[vColumn.Name].ID);

}

a.SaveToXml(SSISPackageFilePath, pkg, null);

th = null;

pkg = null;

a = null;

OLEDBSource = null;

OLEDBDestination = null;

InstanceSource = null;

InstanceDestination = null;

return DTSExecResult.Success;

}

catch (Exception exc)

{

componentEvents.FireError(0, "DynamicDataTransfer.Execute", "Task Errored: " + exc.ToString(), "", -1);

return DTSExecResult.Failure;

}

}

}

}

(Just as a side-note, your blog has helped me a ton since I've started with SSIS. Thanks for posting all of your findings.)

Jess

|||

Hey Jess,

I'm impressed. This is the first time I've seen a working bit of code that does this. Do you mind if I put a link from my blog to this? I think this needs to be shared.

One thing, the correct nomenclature is a custom task, not a custom component. My god, I must be in a critical mood

Regards

-Jamie

|||Custom Task, got it. Sure thing, link to your blog, I'll be proud. Smile|||

JessicaElise wrote:

Custom Task, got it. Sure thing, link to your blog, I'll be proud.

Cool. Done!

Building Packages Programatically

http://blogs.conchango.com/jamiethomson/archive/2007/03/28/SSIS_3A00_-Building-Packages-Programatically.aspx

Thanks again Jess.

-Jamie

|||

Hi Jamie,

Since the Script task only support VB.NET, I'd like to know how the above code can be deployed in our SSIS Package

Are there any conversion tool available?

|||

Subhash512525 wrote:

Hi Jamie,

Since the Script task only support VB.NET, I'd like to know how the above code can be deployed in our SSIS Package

Are there any conversion tool available?

Yes, I'm sure there is. Not being a .Net expert myself I don't know where to find them but I'm sure they exist.

-Jamie

|||

Thanks for your reply Jamie,

I was successful implementing the above code in VB.NET code with slight modifications and additions required for my package using online code converter available here . I must thank you both a lot for the code.

Subhash Subramanyam

|||

Jess,

I was directed to your post by John Welch. I have a need very similar to yours, however, I am not a developer and I am having difficulties implementing your code snippet. I have VS Express for C# loaded and when I create a class library project I get the following error:

The type or namespace name 'Dts' does not exist in the namespace 'Microsoft.SqlServer' (are you missing an assembly reference?)

Can someone point me in the right direction? What other code elements are needed to make this "meat and potatoes" portion work?

Thanks in advance,

Keith

|||

Hi ,

I am also facing this problem, but I didn't understand where I have to write this code. If it is in script task then where is the main() .Can you please tell me or reply on this email address.(ramanandap@.gmail.com).

Thanks in advance

|||

KC wrote:

Jess,

I was directed to your post by John Welch. I have a need very similar to yours, however, I am not a developer and I am having difficulties implementing your code snippet. I have VS Express for C# loaded and when I create a class library project I get the following error:

The type or namespace name 'Dts' does not exist in the namespace 'Microsoft.SqlServer' (are you missing an assembly reference?)

Can someone point me in the right direction? What other code elements are needed to make this "meat and potatoes" portion work?

Thanks in advance,

Keith

You need to add a reference to the Microsoft.SQLServer.DTSRuntimeWrap assembly to your project. Use Project..Add Reference.

|||

Mahi12345 wrote:

Hi ,

I am also facing this problem, but I didn't understand where I have to write this code. If it is in script task then where is the main() .Can you please tell me or reply on this email address.(ramanandap@.gmail.com).

Thanks in advance

This was created as a custom task in VB.NET. That gets compiled to a .NET assembly (DLL), registered in the GAC, and then can be used from your SSIS packages. If you look under "Developing Custom Tasks" in Books Online, you can see more information about this.

Design Question- Dynamic Configuration of Metadata in Dataflow

I have a design question that I'd like some input on. I am trying to archive data from an extremely large production database. The tables to be archived changes quite often. It is currently along the lines of 80-100 tables with the possibility (likelihood) to grow from there.

If at all possible, I'd like to avoid writing an individual dataflow transformation for each table. I know that SSIS does not offer the same capabilities to change the metadata at runtime as DTS. I am currently exploring the option of programmatically creating/modifying the packages through the .Net framework. (using this link as a guide: http://msdn2.microsoft.com/en-us/library/ms345167.aspx).

I have concerns about the performance of this approach and was wondering if anyone had any feedback, or has implemented something similar, or has any other ideas on a different way to accomplish the same thing.

Thanks so much for your help,

Jessica

JessicaElise wrote:

I have a design question that I'd like some input on. I am trying to archive data from an extremely large production database. The tables to be archived changes quite often. It is currently along the lines of 80-100 tables with the possibility (likelihood) to grow from there.

If at all possible, I'd like to avoid writing an individual dataflow transformation for each table. I know that SSIS does not offer the same capabilities to change the metadata at runtime as DTS. I am currently exploring the option of programmatically creating/modifying the packages through the .Net framework. (using this link as a guide: http://msdn2.microsoft.com/en-us/library/ms345167.aspx).

I have concerns about the performance of this approach and was wondering if anyone had any feedback, or has implemented something similar, or has any other ideas on a different way to accomplish the same thing.

Thanks so much for your help,

Jessica

Assuming that the package you build programatically is the same as the package that you build in the SSIS Designer then performance will be exactly the same. Generating the package using the API shouldn't take too long - depends how good a coder you are

To be honest alot of people have mentioned they are attempting this but nobody has reported that they have achieved it. But then again why would they? People come on here to report problems, not successes.

Does that help at all? Probbaly not!!

-Jamie

|||Programmatically creating packages for each table is the way to go unfortunately. Have a look at this link: http://www.ivolva.com/ssis_code_generator.html I haven't used it myself, but if it does what it says, it should be a big help in writing the code to dynamically generate packages.
|||

Well I'm reporting a success, Jamie. I got it working in a very base, proof-of-concept form. I've only tested it for very small datasets though. We'll see what happens when I increase the load (and run it multi-threaded). But, in case this can be of any use to anyone else:

I created a custom component that will create the a dynamic package based on an inputted source table, destination table and package name (source and destination connection strings are currently hardcoded, but I'm going to change that as I develop the component). I've been successful in using this component to create the package and then using the "Execute Package Task" to execute the package that was just created. Chuck that into a ForEach Loop that goes through a recordset containing a DestinationTable, SourceTable, and PackageName and modifies the expressions of the component and it works. Smile

Here's the meat-and-potatoes of the Custom Component I created.

Code Snippet

using System;

using System.Collections.Generic;

using System.Text;

using Microsoft.SqlServer.Dts.Runtime;

using System.IO;

using System.Data;

using Microsoft.SqlServer.Dts.Pipeline;

using Microsoft.SqlServer.Dts.Pipeline.Wrapper ;

namespace DynamicDataTransfer

{

[

DtsTask(

DisplayName = "Dynamic Data Transfer Task",

Description = "Dynamic Data Transfer.",

UITypeName = "DynamicDataTransfer.DynamicDataTransferTaskUI, DynamicDataTransfer, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=xxxxxxxxxxxxxxxx"

)

]

public class DynamicDataTransfer : Task

{

private string SourceTableNameInternal = "";

public string SourceTableName

{

get

{

return this.SourceTableNameInternal;

}

set

{

this.SourceTableNameInternal = value;

}

}

private string PackageNameInternal = "";

public string PackageName

{

get

{

return this.PackageNameInternal;

}

set

{

this.PackageNameInternal = value;

}

}

private string DestinationTableNameInternal = "";

public string DestinationTableName

{

get

{

return this.DestinationTableNameInternal;

}

set

{

this.DestinationTableNameInternal = value;

}

}

/// <summary>

/// Executes the task

/// </summary>

public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)

{

try

{

Microsoft.SqlServer.Dts.Runtime.Application a = new Microsoft.SqlServer.Dts.Runtime.Application();

String SSISPackageFilePath;

SSISPackageFilePath = PackageNameInternal;

if (File.Exists(SSISPackageFilePath))

File.Delete(SSISPackageFilePath);

Package pkg = new Package();

MainPipe dataFlow;

ConnectionManager conMgrSource = pkg.Connections.Add("OLEDB");

ConnectionManager conMgrDestination = pkg.Connections.Add("OLEDB");

conMgrSource.Name = "OLEDBConnectionSource";

conMgrSource.ConnectionString = "Data Source=SOURCESERVER;Initial Catalog=SOURCEDB;Provider=SQLNCLI.1;Integrated Security=SSPI;Auto Translate=False;";

conMgrDestination.Name = "OLEDBConnectionDestination";

conMgrDestination.ConnectionString = "Data Source=DESTINATIONSERVER;Initial Catalog=DESTINATIONDB;Provider=SQLNCLI.1;Integrated Security=SSPI;Auto Translate=False;";

Executable exe = pkg.Executables.Add("DTS.Pipeline.1");

TaskHost th = exe as TaskHost;

th.Name = "DynamicDataFlowTask";

dataFlow = th.InnerObject as MainPipe;

IDTSComponentMetaDataCollection90 metadataCollection = dataFlow.ComponentMetaDataCollection;

IDTSComponentMetaData90 OLEDBSource = dataFlow.ComponentMetaDataCollection.New();

OLEDBSource.Name = "OLEDBSource";

OLEDBSource.ComponentClassID = "DTSAdapter.OLEDBSource.1";

IDTSComponentMetaData90 OLEDBDestination = dataFlow.ComponentMetaDataCollection.New();

OLEDBDestination.Name = "OLEDBDestination";

OLEDBDestination.ComponentClassID = "DTSAdapter.OLEDBDestination.1";

// Get the design time instance of the component.

CManagedComponentWrapper InstanceSource = OLEDBSource.Instantiate();

// Initialize the component

InstanceSource.ProvideComponentProperties();

// Specify the connection manager.

if (OLEDBSource.RuntimeConnectionCollection.Count > 0)

{

OLEDBSource.RuntimeConnectionCollection[0].ConnectionManager = DtsConvert.ToConnectionManager90(pkg.Connections["OLEDBConnectionSource"]);

OLEDBSource.RuntimeConnectionCollection[0].ConnectionManagerID = pkg.Connections["OLEDBConnectionSource"].ID;

}

InstanceSource.SetComponentProperty("OpenRowset", SourceTableNameInternal);

InstanceSource.SetComponentProperty("AccessMode", 0);

//reinitialize the component

InstanceSource.AcquireConnections(null);

InstanceSource.ReinitializeMetaData();

InstanceSource.ReleaseConnections();

// Get the design time instance of the component.

CManagedComponentWrapper InstanceDestination = OLEDBDestination.Instantiate();

// Initialize the component

InstanceDestination.ProvideComponentProperties();

// Specify the connection manager.

if (OLEDBDestination.RuntimeConnectionCollection.Count > 0)

{

OLEDBDestination.RuntimeConnectionCollection[0].ConnectionManager = DtsConvert.ToConnectionManager90(pkg.Connections["OLEDBConnectionDestination"]);

OLEDBDestination.RuntimeConnectionCollection[0].ConnectionManagerID = pkg.Connections["OLEDBConnectionDestination"].ID;

}

InstanceDestination.SetComponentProperty("OpenRowset", DestinationTableNameInternal);

InstanceDestination.SetComponentProperty("AccessMode", 0);

//reinitialize the component

InstanceDestination.AcquireConnections(null);

InstanceDestination.ReinitializeMetaData();

InstanceDestination.ReleaseConnections();

//map the columns

IDTSPath90 path = dataFlow.PathCollection.New();

path.AttachPathAndPropagateNotifications(OLEDBSource.OutputCollection[0], OLEDBDestination.InputCollection[0]);

IDTSInput90 input = OLEDBDestination.InputCollection[0];

IDTSVirtualInput90 vInput = input.GetVirtualInput();

foreach (IDTSVirtualInputColumn90 vColumn in vInput.VirtualInputColumnCollection)

{

IDTSInputColumn90 vCol = InstanceDestination.SetUsageType(input.ID, vInput, vColumn.LineageID, DTSUsageType.UT_READWRITE);

InstanceDestination.MapInputColumn(input.ID, vCol.ID, input.ExternalMetadataColumnCollection[vColumn.Name].ID);

}

a.SaveToXml(SSISPackageFilePath, pkg, null);

th = null;

pkg = null;

a = null;

OLEDBSource = null;

OLEDBDestination = null;

InstanceSource = null;

InstanceDestination = null;

return DTSExecResult.Success;

}

catch (Exception exc)

{

componentEvents.FireError(0, "DynamicDataTransfer.Execute", "Task Errored: " + exc.ToString(), "", -1);

return DTSExecResult.Failure;

}

}

}

}

(Just as a side-note, your blog has helped me a ton since I've started with SSIS. Thanks for posting all of your findings.)

Jess

|||

Hey Jess,

I'm impressed. This is the first time I've seen a working bit of code that does this. Do you mind if I put a link from my blog to this? I think this needs to be shared.

One thing, the correct nomenclature is a custom task, not a custom component. My god, I must be in a critical mood

Regards

-Jamie

|||Custom Task, got it. Sure thing, link to your blog, I'll be proud. Smile|||

JessicaElise wrote:

Custom Task, got it. Sure thing, link to your blog, I'll be proud.

Cool. Done!

Building Packages Programatically

http://blogs.conchango.com/jamiethomson/archive/2007/03/28/SSIS_3A00_-Building-Packages-Programatically.aspx

Thanks again Jess.

-Jamie

|||

Hi Jamie,

Since the Script task only support VB.NET, I'd like to know how the above code can be deployed in our SSIS Package

Are there any conversion tool available?

|||

Subhash512525 wrote:

Hi Jamie,

Since the Script task only support VB.NET, I'd like to know how the above code can be deployed in our SSIS Package

Are there any conversion tool available?

Yes, I'm sure there is. Not being a .Net expert myself I don't know where to find them but I'm sure they exist.

-Jamie

|||

Thanks for your reply Jamie,

I was successful implementing the above code in VB.NET code with slight modifications and additions required for my package using online code converter available here . I must thank you both a lot for the code.

Subhash Subramanyam

|||

Jess,

I was directed to your post by John Welch. I have a need very similar to yours, however, I am not a developer and I am having difficulties implementing your code snippet. I have VS Express for C# loaded and when I create a class library project I get the following error:

The type or namespace name 'Dts' does not exist in the namespace 'Microsoft.SqlServer' (are you missing an assembly reference?)

Can someone point me in the right direction? What other code elements are needed to make this "meat and potatoes" portion work?

Thanks in advance,

Keith

|||

Hi ,

I am also facing this problem, but I didn't understand where I have to write this code. If it is in script task then where is the main() .Can you please tell me or reply on this email address.(ramanandap@.gmail.com).

Thanks in advance

|||

KC wrote:

Jess,

I was directed to your post by John Welch. I have a need very similar to yours, however, I am not a developer and I am having difficulties implementing your code snippet. I have VS Express for C# loaded and when I create a class library project I get the following error:

The type or namespace name 'Dts' does not exist in the namespace 'Microsoft.SqlServer' (are you missing an assembly reference?)

Can someone point me in the right direction? What other code elements are needed to make this "meat and potatoes" portion work?

Thanks in advance,

Keith

You need to add a reference to the Microsoft.SQLServer.DTSRuntimeWrap assembly to your project. Use Project..Add Reference.

|||

Mahi12345 wrote:

Hi ,

I am also facing this problem, but I didn't understand where I have to write this code. If it is in script task then where is the main() .Can you please tell me or reply on this email address.(ramanandap@.gmail.com).

Thanks in advance

This was created as a custom task in VB.NET. That gets compiled to a .NET assembly (DLL), registered in the GAC, and then can be used from your SSIS packages. If you look under "Developing Custom Tasks" in Books Online, you can see more information about this.