Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a database named CommonApps in SQL Server 2008 EXPRESS Advanced. Currently, two apps store their data in this DB. I did this because I did not want to create 2 profiles for all users for accessing these 2 apps. Now it has become hectic to troubleshoot any issues as both apps go offline in case of any issues that arise in both apps. Each of the apps has close to half a million records in the individual tables.
Some imp Tables List in the CommonApps DB(each table has history log table as well)
1.) EmployeeDetails (744 employees as on today)
2.) EmployeeLoginDetails
3.) DailyTask
4.) LeavesTracker
5.) DailyTaskMaster
6.) DailyTaskMasterMetric


I want to copy the data from tables(1 & 2) move the tables(3,5 & 6) of the second app to a new DB named CrossPoint without running into IDENTITY column issues.

How should I go ahead with this?
One is ASP.Net 3.5 Web App on the Intranet IIS Server
Other is Winforms Apps that only runs on the network, not outside it.

What I have tried:

I tried to create the table structure from the CommonApps DB to the CrossPoint DB by taking a no-data script from the CommonApps and then tried running the select * into query but it fails as there a half a million records in the table no 3.
Posted
Updated 29-Apr-18 5:19am

1 solution

A simple way would be to use INSERT INTO...SELECT FROM query to copy the relevant data from database A to database B. After a successful copy, just delete the source rows.

In order to avoid identity problems use SET IDENTITY_INSERT (Transact-SQL) | Microsoft Docs[^]

Also you probably need to re-seed the identity values in the new database using DBCC CHECKIDENT (Transact-SQL) | Microsoft Docs[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900