Skip to content
Advertisement

Insert into a table in another database after first deleting

I have two databases that have same tables on those. First I had to delete all the data in employee_table in Database_1. Then after that I need to insert data in the employee_table in Database_2 to the employee_table in the Database_1.

I am using SQL Server Management Studio 2017.

Is there any solution for this?

Advertisement

Answer

You should first insert data to database_2 and then delete from database 1 with this command:

INSERT INTO [Database_2].dbo.emplyee_table
SELECT * From [Database_1].dbo.employee_table

DELETE FROM [Database_1].dbo.employee_table
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement