Vaas Montenegro
Vaas Montenegro

Reputation: 27

How can I transfer data from one table to another, overwriting old data?

I need some help for transfering data from one table to another.

enter image description here

As you can see there are 2 databases.

I would like to transfer the table datas "PinterSet" located in the database Contrinex.GPO in the table "PrinterSet" located in the database Contrinex.GPOQA.

There are already datas in the table "PrinterSet" of Contrinex.GPOQA but I would overwrite and put the datas from "PrinterSet" of Contrinex.GPO.

So how can I do that ?

Upvotes: 0

Views: 854

Answers (4)

user3583912
user3583912

Reputation: 1322

here is your code..

truncate table Contrinex.GPOQA.dbo.PrinterSet
go
insert into Contrinex.GPOQA.dbo.PrinterSet
select * from Contrinex.GPO.dbo.PrinterSet

Upvotes: 2

Krishna P S
Krishna P S

Reputation: 350

You can use Sql Server Export functianality, where you can transfer data from one table to another across Database.

Please refer the below link on using the SQL Server Export

http://searchsqlserver.techtarget.com/feature/The-SQL-Server-Import-and-Export-Wizard-how-to-guide

Upvotes: 0

Uday
Uday

Reputation: 9

select data from first database table and insert it into the second database table as

INSERT INTO GPOQA.PrinterSet SELECT * from GPO.PrinterSet

if want some perticular columns then set column names as

INSERT INTO GPOQA.PrinterSet a SET a.column1=b.column1,.... SELECT column1,... from GPO.PrinterSet b

Upvotes: 0

Devart
Devart

Reputation: 122002

TRUNCATE TABLE [Contrinex.GPOQA].dbo.PinterSet
GO
INSERT INTO [Contrinex.GPOQA].dbo.PinterSet (...)
SELECT ...
FROM [Contrinex.GPO].dbo.PinterSet

Upvotes: 1

Related Questions