copy database table values to another database table ...

Posted by Gopal_nivas under C# on 10/23/2009 | Views : 2914 | Status : [Member] | Replies : 3
hi..

i want to copy one database table values and to insert that table values to another database table in sqlserver..

(both table having same structure)

how to do this through coding..

need ur suggestions..


regards

gopal.s




Responses

Posted by: Santosh4u on: 10/25/2009 [Member] Bronze

Up
0
Down
hi Gopal_nivas
if want to do through coding then it it lissle bit diffcult.
so through coding,first u need to fetch all the records from database and after that u use the multi-insert concept to insert these records.

Regards
Santosh


Gopal_nivas, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 10/26/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Simple

lets Say i have this

Database1

Create Table Table1

(
Name varchar(30),
Lastname varchar(30)
)


and
Database2

Create Table Table2

(
Name varchar(30),
Lastname varchar(30)
)



and you want to copy records from table1 from Database1, you would do it like this

INSERT INTO DATABASE2.DBO.TABLE2
SELECT [NAME],[LASTNAME] FROM DATABASE1.DBO.TABLE1


The above Query would bring all the record from table 1 in Database one into Table2 in Database 2

Thank you for posting at dotnetfunda

Vuyiswa Maseko


Thank you for posting at Dotnetfunda
[Administrator]

Gopal_nivas, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajeev16mca2k5 on: 10/26/2009 [Member] Starter

Up
0
Down
If you dont have second table , i mean to say, if you want to create new table that will contain either complete or some data of existing table, then you can do as select */fieldname(s) into 'newtablename' from 'oldtablename' where condition

Gopal_nivas, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response