Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 How to create variables to populate a table?

Author  Topic 

pras2007
Posting Yak Master

216 Posts

Posted - 2012-10-18 : 08:32:21
Hello All,
I have several destination tasks in my data flow. What I want is once each destination task has completed, I want to insert the following into a table called “LoadStatus”:
- RecordCount
- TableName
- LoadTime
Please see the below example table:
LoadStatusID DateTimeEntry RecordCount TableName LoadTime
1 10/18/12 7:46 AM 45454 1stTable 200
2 10/18/12 7:47 AM 63472 2ndTable 348
3 10/18/12 7:48 AM 19352 3rdTable 123

Below is the create table statement:
CREATE TABLE [dbo].[LoadStatus](
[LoadStatusID] [int] IDENTITY(1,1) NOT NULL,
[DateTimeEntry] [datetime] NULL,
[RecordCount] [int] NULL,
[TableName] [nchar](50) NULL,
[LoadTime] [nchar](10) NULL,
CONSTRAINT [PK_LoadStatus] PRIMARY KEY CLUSTERED
(
[LoadStatusID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[LoadStatus] ADD CONSTRAINT [DF_LoadStatus_DateTimeEntry] DEFAULT (getdate()) FOR [DateTimeEntry]
GO

What is needed to accomplish this goal?
Thanks.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-10-18 : 13:05:09
you need to add a logic in event handler for OnPostExecute event of above data flow tasks for that. The logic will be an Execute SQL task which does insertion to LoadStatus table. You can use RowCount tansform to capture count of rows in data flow.
Another way is to use t-sql procedure to capture this information. But you should have a field to identify unique package executions for that in your table.



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -