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 |
|
SamC
White Water Yakist
3467 Posts |
Posted - 2002-07-16 : 19:07:35
|
| Here's another update problem I have. Occasionally, new "organization" names get slipped into a spreadsheet containing thousands of user records. I need a query to isolate the "new" organizations and insert them into a table named "org". This query will isolate new organizations Select * from spreadsheet left outer join org on org.orgname=spreadsheet.orgname where org.orgname is null But that select may yield 200 rows for a single new organization name. How can the query be modified to insert the new name once into the table "org"? Insert into org (orgname) from ........... Without inserting the same orgname 200 times? SamC |
|
|
chadmat
The Chadinator
1974 Posts |
Posted - 2002-07-17 : 00:23:44
|
| Use the DISTINCT keyword.-Chad |
 |
|
|
rksingh024
Yak Posting Veteran
56 Posts |
Posted - 2002-07-17 : 02:56:55
|
| Use Select Top 1 * from TablenameRamesh |
 |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2002-07-17 : 03:45:15
|
| insert into orgSelect DISTINCT spreadsheet.orgname from spreadsheet left outer join org on org.orgname=spreadsheet.orgname where org.orgname is null PeaceRick |
 |
|
|
SamC
White Water Yakist
3467 Posts |
Posted - 2002-07-17 : 15:33:44
|
| Thanks to everyone who responded. It didn't occur to me that there might be a DISTINCT keyword, so my search had been along the lines of compares, CASE, GROUP. DISTINCT solved my immediate problem and will remain useful in the days ahead.SamC |
 |
|
|
|
|
|