Pramodi Samaratunga
Pramodi Samaratunga

Reputation: 565

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?

Upvotes: 0

Views: 189

Answers (1)

ali sadeghi
ali sadeghi

Reputation: 121

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

Upvotes: 3

Related Questions