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

Sequence number column in destination table not in source table Expand / Collapse
Author
Message
Posted Monday, March 16, 2009 3:59 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, November 6, 2014 8:36 AM
Points: 20, Visits: 486
Sequence number column in destination table not in source table.

I have an issue when i m migrating the data from sqlserver to sqlserver database.

the column seq number is in destination table(not in source table) which can write the records sequentially at the time of inserting the data in to destation table.

Please give any sample code for this.

what is tyhe approach for this.

Reply ASAP.

Thanks.
Post #677015
Posted Monday, March 16, 2009 7:32 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 12:24 AM
Points: 5,317, Visits: 12,355
Is the sequence number arbitrary? If so, why not make it an IDENTITY(1,1) field in the destination table and then SQL Server will take care of the numbering for you.


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.

It is better to keep your mouth shut and appear stupid than to open it and remove all doubt. (Mark Twain)
Post #677108
Posted Monday, March 16, 2009 9:15 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, November 6, 2014 8:36 AM
Points: 20, Visits: 486
There is sequence number column in destination table(there is no mapping filed in source table).When update or insert the data in to destination table the sequence number field should be in destination table along with sequence number which record(increments based no of times the record is updated) is updated and inserted in to destination table.

Thanks.
Post #677138
Posted Monday, March 16, 2009 9:40 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 12:24 AM
Points: 5,317, Visits: 12,355
So a sequence number of 8 means the record was INSERTED once and updated seven times (1 + 7 = 8)?


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.

It is better to keep your mouth shut and appear stupid than to open it and remove all doubt. (Mark Twain)
Post #677149
Posted Tuesday, March 17, 2009 6:55 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, November 6, 2014 8:36 AM
Points: 20, Visits: 486
yes,how should i create an ssis package.

give me any example with sample code.

thanks.
Post #677389
Posted Tuesday, March 17, 2009 7:29 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 12:24 AM
Points: 5,317, Visits: 12,355
Hmmm, you really need an example for this?

Something along the following lines (untested & I'm getting tired):

INSERT INTO DestTable(Field1, Fieldn, SeqNo)
SELECT S.Field1, S.Fieldn, 1
FROM SourceTable S
WHERE [Source record not in Destination table]

UPDATE DestTable
SET Field1 = S.Field1, Fieldn = S.Fieldn, SeqNo = SeqNo + 1
FROM SourceTable S
WHERE S.Keyfield = DestTable.Keyfield




Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.

It is better to keep your mouth shut and appear stupid than to open it and remove all doubt. (Mark Twain)
Post #677424
Posted Tuesday, March 17, 2009 8:59 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, November 6, 2014 8:36 AM
Points: 20, Visits: 486
I m little bit confused with the code which u sent as an example.

canu make it clear.

Thanks.
Post #677557
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse