all groups > sql server data mining > december 2003 >
You're in the

sql server data mining

group:

Help me combine / delete duplicates across two tables..



Help me combine / delete duplicates across two tables.. Richard Morey
12/12/2003 3:03:00 PM
sql server data mining: Hi,

I am at a total loss as to how to accomplish a task..

I have one table with two sets of values.. like this

1000,september
1234,september
1566,september
2000,october
2010,october
2022,october

and a second table with one set of values

1000
1234
1000
1566
1000
2000
2010
2011
2022
2000
2010


What I would like to to is change the values in table 2 so that all the
"Septembers" (represented in this example by 1000,1234,1566) change to 1000
and then delete the other values (1234,1566) from table 1..

I can't do this simply by # because this scenerio comes from a data
conversion routine and the numbers wont' be known until "run time"..

So I need a query that can change the values in the second table based on
the first table and then delete the duplicate values in the first table..

As I said, I'm at a total loss as to where to even start..

Thanks

Rich

Re: Help me combine / delete duplicates across two tables.. Richard Morey
12/12/2003 3:55:35 PM
Okay, I got this far..

set @varSEASON = 'OCT-MAY'

UPDATE tablerentals SET SEASON = (SELECT TOP 1 SEASON FROM
lookupTableRentalSeasons where seasonname = @varSEASON) where season in
(select season from lookupTableRentalSeasons where seasonname = @varSEASON)

Is there any way in the query analyzer to select a dataset and iterate
through it and perform the above for each record, obviously setting the
variable to the value each time.. ?

Rich

[quoted text, click to view]

Re: Help me combine / delete duplicates across two tables.. Raman Iyer [MS]
12/18/2003 7:12:18 PM
Forwarding to a more appropriate NG.

--
Raman Iyer
SQL Server Data Mining
[Please do not send email directly to this alias. This alias is for
newsgroup purposes and is intended to prevent automated spam. This posting
is provided "AS IS" with no warranties, and confers no rights.]
..

[quoted text, click to view]

AddThis Social Bookmark Button