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 |
|
Crespo
85 Posts |
Posted - 2002-04-25 : 06:11:12
|
| Hi there,I have a very tight deadline and I need to get this migration done in the next 48 hours. This is just a small problem which I don't have to do at the moment as I am working on a more complicated script.Here is the problem and what I need from one of you guys to help me with.INSERT INTO AHD_CHAR (MEMBERKEY, EFFDATE, DATE1, AMOUNT1, AMOUNT2, AMOUNT3, DATE2)SELECT CONVERT(CHAR(100),MEMBER_KEY), CONVERT(CHAR(100),DATE1,103), CONVERT(CHAR(100),DATE1,103), CONVERT(CHAR(100),CONVERT(DECIMAL(10,2),AMOUNT1)), CONVERT(CHAR(100),CONVERT(DECIMAL(10,2),AMOUNT2)), CONVERT(CHAR(100),CONVERT(DECIMAL(10,2),AMOUNT3)), CONVERT(CHAR(100),DATE2,103)FROM GNS_AHD AS A, SCHEMEMEMBER_CHAR AS BWHERE A.MEMBER_KEY = B.MEMBERKEYNow if a member key has two entries with the same DATE1 then there is a problem.What I need is some nice piece if code, some PL/SQL or cursor to find memberkeys with two entries that have the same DATE1. If that is the case then the first memberkey is inserted to the table, but the second one is incremented by 1 and inserted into the EFFDATE column.If the memberkey has three DATE1 fields with the same data, then the third date is incremented by 2 etc. Does it makee sense and if so, could somebody help me out on this as I really don't have time to work on this right now.Good Luck!Crespo. |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2002-05-17 : 13:54:50
|
create table #blah (member_key int, date1 datetime)insert #blahselect 1,'1/1/01' union allselect 1,'1/1/01' union allselect 1,'1/1/01' union allselect 2,'1/1/01'declare @counter intset @counter = -1update #blahset date1 = date1 + @counter, @counter = @counter + 1where member_key in ( select member_key from #blah group by member_key having count(*) > 1 )select * from #blahdrop table #blah Ok, so its a couple days late . . .but cursor-smursor (and pl/sql-pl/smequel . . . ) <O> |
 |
|
|
|
|
|
|
|