Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
David Lopez
Starting Member
19 Posts |
Posted - 2005-06-22 : 12:11:05
|
| Hi, I am trying to copy data from an old(different) tabel to a new one. I am using===INSERT INTO Client(name)VALUES mae_cli.nameFROM mae_cliWHERE mae_cli.province = 'provinceNAME'===But it gives me errors.The length of the camps are the same varchar(40).Anybody with some help, I am new to thisThxDavid |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2005-06-22 : 12:38:52
|
CodeINSERT INTO Client(name)VALUES (select column_name FROM mae_cliWHERE mae_cli.province = 'provinceNAME') |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-06-23 : 01:41:53
|
quote: Originally posted by afrika CodeINSERT INTO Client(name)VALUES (select column_name FROM mae_cliWHERE mae_cli.province = 'provinceNAME')
Small Correction. Dont use ValuesINSERT INTO Client(name)(select name FROM mae_cliWHERE mae_cli.province = 'provinceNAME') MadhivananFailing to plan is Planning to fail |
 |
|
|
David Lopez
Starting Member
19 Posts |
Posted - 2005-06-23 : 02:17:15
|
| Thx all,is there also a simple way to copy the data from the old DB to the new DB? BUT the amount/names of the colums aren´t the same!!The old DB has about 40 columns and the new one has about 200 colums. Still I only need to copy the 40 columns into some 40 columns of the new DB. STILL, the names of the columns are different. Is there a simple way to do that????It would really help me with my problem.Many thx alrreadyDavid |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-06-23 : 02:24:22
|
| Insert into NewTable (col1,col2...col40)Select col1,col2,..col40 from OldTableMadhivananFailing to plan is Planning to fail |
 |
|
|
David Lopez
Starting Member
19 Posts |
Posted - 2005-06-23 : 02:57:13
|
| Thx,but can I for example skip some colums from the first table (the new one), because some colums are new and don´t contain data?something likeInsert into NewTable (col1,col5...col140)Select col1,col32,..col99 from OldTablemany thx |
 |
|
|
David Lopez
Starting Member
19 Posts |
Posted - 2005-06-23 : 03:23:11
|
quote: Originally posted by madhivanan
quote: Originally posted by afrika CodeINSERT INTO Client(name)VALUES (select column_name FROM mae_cliWHERE mae_cli.province = 'provinceNAME')
Small Correction. Dont use ValuesINSERT INTO Client(name)(select name FROM mae_cliWHERE mae_cli.province = 'provinceNAME') MadhivananFailing to plan is Planning to fail
Can you for example INSERT some columns with a combination of values and also SELECTS?I Mean something like this:===INSERT INTO Clients(CodigoEmpresa, IdDelegacion, CodigoCliente, COD_LANG)VALUES (9999, 'BAR', SELECT COD_CLI FROM OLD_TABLE, 'ES')=== |
 |
|
|
|
|
|
|
|