Author |
Topic |
picatshou
Starting Member
12 Posts |
Posted - 2014-04-19 : 17:49:17
|
hievery body i want to insert the values of a column from one table to the column in one other table i don't want to specify values because there are many values in the column how can i do that so ?part of table one :NAME numberjim 12tim 16ketty 19table 2:identif num classi want to insert values in columns name and number from table 1 into identif and num of table 2Thanks a lot for any answer |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2014-04-19 : 18:03:07
|
insert t2 (identif, num)select name, numberfrom t1==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
picatshou
Starting Member
12 Posts |
Posted - 2014-04-19 : 18:11:03
|
thnx but it shows error in clause from ! |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2014-04-19 : 18:19:57
|
What is the error - you need to substitute your table name for t1. Maybe enclose identifiers in square brackets and make sure you have the correct case if you are case sensitive.You are using sql server?insert [table 2] ([identif], [num])select [name], [number]from [Table one]==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
picatshou
Starting Member
12 Posts |
Posted - 2014-04-19 : 18:25:09
|
yes i am using sql server 2008 now it shows the message :this instruction is not a request ! |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2014-04-19 : 18:27:42
|
How are you executing it?Try select 1and see what happens==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2014-04-19 : 18:31:19
|
A search for that error message brings back no results which makes me think something odd is going on.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
picatshou
Starting Member
12 Posts |
Posted - 2014-04-19 : 18:34:54
|
when i execute one other it works !in fact the select is from a table excel i clic import then sql request so table 2 is an axcel file and table 2 is sqlserver table one other remarque is that there is no into in your request so it shows error insert into !and then when i put into it shows it is not a request i don't know what i will do ?! |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2014-04-19 : 19:11:54
|
the into is optional in an sql server query statement - that's why I ask how you are executing this.tryselect top 10 *from [table one]How are you connecting to the excel file - a linked server?==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
picatshou
Starting Member
12 Posts |
Posted - 2014-04-19 : 19:17:05
|
this request works !but the other one no!to connect to excel by right click on the name of data base then i choose (tâches ->importer des données) |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2014-04-19 : 19:31:57
|
That will import data into a table. You then need to use that table in a query to insert into your final table.Another option is to use ssis (which is what your import is doing) to import into your final table.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
|