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 |
|
kgundava
Yak Posting Veteran
66 Posts |
Posted - 2011-08-09 : 11:15:18
|
| Hi All,I have two tables(A,B) in two different linked servers.Now i want to retrieve the identical data from both the tables and load it into a table(ssql server).FOr this i am first creating a table in Sql server based on TABLE A.select * into TEST from LINKEDSERVERA..TED.TABLEA where 1=2Note: TABLE A has 3 extra columns than TABLE B.Once the table is created I am now going ahead and using this statement below to get the identical data and insert (inner join based on unique composite key) INSERT INTO TEST SELECT * FROM LINKEDSERVERA..TED.TABLEA T inner join LINKEDSERVERB..TED.TABLEB S on S.[GJAHR]=T.[GJAHR] and S.[BELNR]=T.[BELNR] and S.[BUZEI]=T.[BUZEI] when i run the above query i am getting the below Msg 213, Level 16, State 1, Line 1Column name or number of supplied values does not match table definition.Please let me know where i am going wrong.Thanks....... |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2011-08-09 : 11:35:47
|
Whenever you do an insert, you should explicitly list the columns, and not use *. INSERT INTO TEST (Col1, Col2, Col3, Col4) SELECT 'value1','value2','value3','value4' http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspxHow to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
|
|
|
|
|