Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How to insert records based on Audit Table Expand / Collapse
Author
Message
Posted Friday, October 05, 2012 2:47 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Tuesday, March 12, 2013 3:57 AM
Points: 93, Visits: 237
Audit table:

CREATE TABLE [dbo].[AUDIT_RECORD](
[FILENAME] [varchar](100) NULL,
[LOAD_DATE] [datetime] NULL
)
Insert into [dbo].[AUDIT_RECORD] values('Sample',12/09/2012)
Insert into [dbo].[AUDIT_RECORD] values('Sample',13/09/2012)

----------------------------------------------------
DB Table:

CREATE TABLE [dbo].[Sample1](
[pKey] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
[SasId] [nvarchar](max) NULL,
[Name] [nvarchar](max) NULL,
[TypeId] [nvarchar](max) NULL,
[UserName] [nvarchar](max) NULL,
[SysCreatedDateTime] [datetime] NULL,
[CompletedDateTime] [datetime] NULL,
[Boolean] [bit] NULL,
)

insert into Sample1 values('sdf','werwer','s233','xzfdsdf',12/11/2011,14/11/2011,'TRUE')

----------------------------------------

Ques:

Have a table “Sample1” and one of the columns is “SysCreatedDateTime”
Need to transfer the records from a table(Sample1) to another table(Sample2) based on the below condition

Condition:
Sample.SysCreatedDateTime > [dbo].[AUDIT_RECORD].MAX(LOAD_DATE)

How will we do this using SSIS 2005?


Regards
Sql
Post #1368881
Posted Friday, October 05, 2012 3:10 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 9:27 AM
Points: 5,618, Visits: 10,990
sqlstud (10/5/2012)
...

How will we do this using SSIS 2005?

Regards
Sql


SSIS is a bit overkill for this.
INSERT INTO ...
SELECT... FROM ... WHERE ...


“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Exploring Recursive CTEs by Example Dwain Camps
Post #1368893
Posted Friday, October 05, 2012 3:26 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, April 23, 2013 10:52 PM
Points: 2,118, Visits: 343
you can use execute sql script task and there you write one script of select * into...
Post #1368902
Posted Wednesday, October 10, 2012 12:30 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Tuesday, March 12, 2013 3:57 AM
Points: 93, Visits: 237
Thanks Chris and Div

Regards
Sqlstud
Post #1370704
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse