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 |
|
shobha
Starting Member
1 Post |
Posted - 2002-06-17 : 17:09:21
|
| What would be the sql query if I want to insert some fields in a new table from 5 different tables. These 5 tables have one common field (nycuid). I used following query but getting error.insert into collectall select nycuid, nycName, nycAddress, nycDunsNumber union select associd, assocName, assocAddress, assocDunsNumber union select duid, duName, duAddress, duDuns union select guid, guName, guAddress, guDuns union select hpid, hpName, hpAddress, hpDuns from nysCompany, assocCompany1, duCompany1, guCompany1, hpCompany1wherenysCompany.nycuid=assocCompany1.nycuid andnysCompany.nycuid=DuCompany1.nycuid andnysCompany.nycuid=guCompany1.nycuid andnysCompany.nycuid=hpCompany1.nycuid |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2002-06-17 : 18:49:22
|
| You need to go back and look up UNION in Books Online; you're syntax is wrong. The UNION operator combines the results of two or more queries into a single rowset. Once you sort out the UNION, your insert should work (assuming the columns in your table match the rowset: it is best practice to explicitly name the columns in an insert statement.)<O> |
 |
|
|
|
|
|
|
|