I have old sql express 05 database where some tables contains important data that is want to transfer to new sql express 05 database.
I want to preserve auto ids of old data in tables, but dont want to transfer all tables only some tables i want to transfer, but problem is I have to achieve this using c# 3.5 winform app
My tasks are:
Anybody have good approch to acchive it using c#,stored procedurs etc.
use winform to launch an SSIS package programmatically.
http://msdn.microsoft.com/en-us/library/ms136090.aspx
you'll have to buy (or msdn download perhaps?) sql developer edition to get integration services (SSIS)
Check if SQL express accepts this command: set identity sales on, or similar; this will allow you to insert the data from the old table(s) to the new table and keeping your existing identity values in the new tables.
I would use a store procedure to do the data transfer work. You can call/execute the procedure from your C# winform app.
Before inserting the data, set the identity option on for each table you want to transfer data.
The command to transfer data for each table can be something like:
Set identity newtable on
insert into newtable (identitycolum, column1, column2, column3)
Select identitycolum, column1, column2, column3 From oldtable
Set identity newtable off
Hope that helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.