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 |
shaw
Starting Member
15 Posts |
Posted - 2007-05-07 : 14:52:23
|
hi there,when i use the below script to insert 2 columns of a table(named actual flow) into an already existing table (named merged2):insert into merged2select ustie, abtiefrom actual_flowi get the following error message:Msg 213, Level 16, State 1, Line 2Insert Error: Column name or number of supplied values does not match table definition.i created 2 columns in merged2 table, named ustie and abtie and the number of values equal to each other in those two tables.can you see where I am making a mistake?thanks, |
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2007-05-07 : 14:56:31
|
[code]INSERT INTO merged2 (ColumnNameOne, ColumnNameTwo)SELECT ustie,abtieFROM actual_flow[/code]ColumnNameOne being the name of the first column in merged2, etc.[Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQLhttp://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2007-05-07 : 14:57:57
|
Try This insert merged2 (ustie,abtie)select ustie, abtiefrom actual_flowAnd also if you are not concern with the primary key, index etc then you create the table with Select into statement like this select ustie, abtie Merged2 from actual_flow Chiraghttp://chirikworld.blogspot.com/ |
|
|
shaw
Starting Member
15 Posts |
Posted - 2007-05-07 : 15:02:45
|
i tried:insert merged2 (ustie,abtie)select ustie, abtiefrom actual_flowi got:Msg 515, Level 16, State 2, Line 2Cannot insert the value NULL into column 'KEY', table 'CABREE.dbo.merged2'; column does not allow nulls. INSERT fails.The statement has been terminated.it tries to put my values into my first column, but I want to put those values into my last two columns, named ustie and abtie.the column KEY is my first column's name, and it tries to put the values in that column.i don't get why.. |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2007-05-07 : 15:15:05
|
Can you post the table structure and same sample data for better understanding..!!Chiraghttp://chirikworld.blogspot.com/ |
|
|
|
|
|
|
|