![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
How would one go about doing this: Table 1: DimA Type FromDimB ToDimB 123 A 1 2 456 B 1 2 789 C 3 8 Table 2: DimB Type DimA 1 A 123 2 A 123 2 B 456 3 C 789 4 C 789 5 C 789 For now there is no DimA column in table 2 so I have to make this either by joining or cursor ? What would be the best approach - making a cursor on Table 1 and updatering table 2 in steps ? \Michael Vardinghus |
#3
| |||
| |||
|
|
How would one go about doing this: Table 1: DimA Type FromDimB ToDimB 123 A 1 2 456 B 1 2 789 C 3 8 Table 2: DimB Type DimA 1 A 123 2 A 123 2 B 456 3 C 789 4 C 789 5 C 789 For now there is no DimA column in table 2 so I have to make this either by joining or cursor ? What would be the best approach - making a cursor on Table 1 and updatering table 2 in steps ? \Michael Vardinghus |
#4
| |||
| |||
|
|
Think i got it solved by this - seems to work okay...i'm not updating in this example - so the select will be replaced with an update sentence USE um_dw_finance_staging DECLARE @delregnskab int, @frasag int , @tilsag int, @titel varchar (40) DECLARE led1_cursor CURSOR FOR SELECT delregnskab, frasag, tilsag, titel FROM led1sortering order by delregnskab, frasag, tilsag, titel OPEN led1_cursor FETCH NEXT FROM led1_cursor into @delregnskab, @frasag, @tilsag, @titel WHILE @@FETCH_STATUS = 0 BEGIN select *, @titel from dbo.finansbudgetposter_staging post where post.delregnskab = @delregnskab and post.sagsbudget >= @frasag and post.sagsbudget <= @tilsag FETCH NEXT FROM led1_cursor into @delregnskab, @frasag, @tilsag, @titel END CLOSE authors_cursor DEALLOCATE authors_cursor GO "Michael Vardinghus" <michaelvardinghus (AT) notexisting (DOT) com> skrev i en meddelelse news:%23RkbWCMTEHA.3608 (AT) TK2MSFTNGP11 (DOT) phx.gbl... How would one go about doing this: Table 1: DimA Type FromDimB ToDimB 123 A 1 2 456 B 1 2 789 C 3 8 Table 2: DimB Type DimA 1 A 123 2 A 123 2 B 456 3 C 789 4 C 789 5 C 789 For now there is no DimA column in table 2 so I have to make this either by joining or cursor ? What would be the best approach - making a cursor on Table 1 and updatering table 2 in steps ? \Michael Vardinghus |
#5
| |||
| |||
|
|
Hi How about: select p.*, l.titel from dbo.finansbudgetposter_staging p JOIN dbo.led1sortering l ON p.delregnskab = l.delregnskab and p.sagsbudget >= l.frasag and p.sagsbudget <= l.tilsag order by l.delregnskab, l.frasag, l.tilsag, l.titel A single result set will make the code that processes the results easier! John "Michael Vardinghus" <michaelvardinghus (AT) notexisting (DOT) com> wrote in message news:uZLZNpMTEHA.2416 (AT) TK2MSFTNGP09 (DOT) phx.gbl... Think i got it solved by this - seems to work okay...i'm not updating in this example - so the select will be replaced with an update sentence USE um_dw_finance_staging DECLARE @delregnskab int, @frasag int , @tilsag int, @titel varchar (40) DECLARE led1_cursor CURSOR FOR SELECT delregnskab, frasag, tilsag, titel FROM led1sortering order by delregnskab, frasag, tilsag, titel OPEN led1_cursor FETCH NEXT FROM led1_cursor into @delregnskab, @frasag, @tilsag, @titel WHILE @@FETCH_STATUS = 0 BEGIN select *, @titel from dbo.finansbudgetposter_staging post where post.delregnskab = @delregnskab and post.sagsbudget >= @frasag and post.sagsbudget <= @tilsag FETCH NEXT FROM led1_cursor into @delregnskab, @frasag, @tilsag, @titel END CLOSE authors_cursor DEALLOCATE authors_cursor GO "Michael Vardinghus" <michaelvardinghus (AT) notexisting (DOT) com> skrev i en meddelelse news:%23RkbWCMTEHA.3608 (AT) TK2MSFTNGP11 (DOT) phx.gbl... How would one go about doing this: Table 1: DimA Type FromDimB ToDimB 123 A 1 2 456 B 1 2 789 C 3 8 Table 2: DimB Type DimA 1 A 123 2 A 123 2 B 456 3 C 789 4 C 789 5 C 789 For now there is no DimA column in table 2 so I have to make this either by joining or cursor ? What would be the best approach - making a cursor on Table 1 and updatering table 2 in steps ? \Michael Vardinghus |
#6
| |||
| |||
|
|
Didn't think i could join like that...wouw... And I couldn't aggree more....would avoid cursors if possible - didn't think i could join... \Michael V "John Bell" <jbellnewsposts (AT) hotmail (DOT) com> skrev i en meddelelse news:uQgeIwTTEHA.4048 (AT) TK2MSFTNGP12 (DOT) phx.gbl... Hi How about: select p.*, l.titel from dbo.finansbudgetposter_staging p JOIN dbo.led1sortering l ON p.delregnskab = l.delregnskab and p.sagsbudget >= l.frasag and p.sagsbudget <= l.tilsag order by l.delregnskab, l.frasag, l.tilsag, l.titel A single result set will make the code that processes the results easier! John "Michael Vardinghus" <michaelvardinghus (AT) notexisting (DOT) com> wrote in message news:uZLZNpMTEHA.2416 (AT) TK2MSFTNGP09 (DOT) phx.gbl... Think i got it solved by this - seems to work okay...i'm not updating in this example - so the select will be replaced with an update sentence USE um_dw_finance_staging DECLARE @delregnskab int, @frasag int , @tilsag int, @titel varchar (40) DECLARE led1_cursor CURSOR FOR SELECT delregnskab, frasag, tilsag, titel FROM led1sortering order by delregnskab, frasag, tilsag, titel OPEN led1_cursor FETCH NEXT FROM led1_cursor into @delregnskab, @frasag, @tilsag, @titel WHILE @@FETCH_STATUS = 0 BEGIN select *, @titel from dbo.finansbudgetposter_staging post where post.delregnskab = @delregnskab and post.sagsbudget >= @frasag and post.sagsbudget <= @tilsag FETCH NEXT FROM led1_cursor into @delregnskab, @frasag, @tilsag, @titel END CLOSE authors_cursor DEALLOCATE authors_cursor GO "Michael Vardinghus" <michaelvardinghus (AT) notexisting (DOT) com> skrev i en meddelelse news:%23RkbWCMTEHA.3608 (AT) TK2MSFTNGP11 (DOT) phx.gbl... How would one go about doing this: Table 1: DimA Type FromDimB ToDimB 123 A 1 2 456 B 1 2 789 C 3 8 Table 2: DimB Type DimA 1 A 123 2 A 123 2 B 456 3 C 789 4 C 789 5 C 789 For now there is no DimA column in table 2 so I have to make this either by joining or cursor ? What would be the best approach - making a cursor on Table 1 and updatering table 2 in steps ? \Michael Vardinghus |
#7
| |||
| |||
|
|
Hi Time spent reading books online will repay itself ! You may also want to check out Itzik's articles on http://www.winnetmag.com/SQLServer/ or subscribe to the printed version! His (and Tom's) book at: http://search.barnesandnoble.com/boo...sbn=1893115828 is certainly one for every bookshelf and there are many others! A more comprehensive list can be found at: http://www.aspfaq.com/show.asp?id=2423 John "Michael Vardinghus" <michaelvardinghus (AT) notexisting (DOT) com> wrote in message news:uWsJ41TTEHA.3548 (AT) TK2MSFTNGP09 (DOT) phx.gbl... Didn't think i could join like that...wouw... And I couldn't aggree more....would avoid cursors if possible - didn't think i could join... \Michael V "John Bell" <jbellnewsposts (AT) hotmail (DOT) com> skrev i en meddelelse news:uQgeIwTTEHA.4048 (AT) TK2MSFTNGP12 (DOT) phx.gbl... Hi How about: select p.*, l.titel from dbo.finansbudgetposter_staging p JOIN dbo.led1sortering l ON p.delregnskab = l.delregnskab and p.sagsbudget >= l.frasag and p.sagsbudget <= l.tilsag order by l.delregnskab, l.frasag, l.tilsag, l.titel A single result set will make the code that processes the results easier! John "Michael Vardinghus" <michaelvardinghus (AT) notexisting (DOT) com> wrote in message news:uZLZNpMTEHA.2416 (AT) TK2MSFTNGP09 (DOT) phx.gbl... Think i got it solved by this - seems to work okay...i'm not updating in this example - so the select will be replaced with an update sentence USE um_dw_finance_staging DECLARE @delregnskab int, @frasag int , @tilsag int, @titel varchar (40) DECLARE led1_cursor CURSOR FOR SELECT delregnskab, frasag, tilsag, titel FROM led1sortering order by delregnskab, frasag, tilsag, titel OPEN led1_cursor FETCH NEXT FROM led1_cursor into @delregnskab, @frasag, @tilsag, @titel WHILE @@FETCH_STATUS = 0 BEGIN select *, @titel from dbo.finansbudgetposter_staging post where post.delregnskab = @delregnskab and post.sagsbudget >= @frasag and post.sagsbudget <= @tilsag FETCH NEXT FROM led1_cursor into @delregnskab, @frasag, @tilsag, @titel END CLOSE authors_cursor DEALLOCATE authors_cursor GO "Michael Vardinghus" <michaelvardinghus (AT) notexisting (DOT) com> skrev i en meddelelse news:%23RkbWCMTEHA.3608 (AT) TK2MSFTNGP11 (DOT) phx.gbl... How would one go about doing this: Table 1: DimA Type FromDimB ToDimB 123 A 1 2 456 B 1 2 789 C 3 8 Table 2: DimB Type DimA 1 A 123 2 A 123 2 B 456 3 C 789 4 C 789 5 C 789 For now there is no DimA column in table 2 so I have to make this either by joining or cursor ? What would be the best approach - making a cursor on Table 1 and updatering table 2 in steps ? \Michael Vardinghus |
#8
| |||
| |||
|
Actually bougth sql for gurus....perhaps i should try to read it...![]() "John Bell" <jbellnewsposts (AT) hotmail (DOT) com> skrev i en meddelelse news:uIHEkaUTEHA.1472 (AT) TK2MSFTNGP09 (DOT) phx.gbl... Hi Time spent reading books online will repay itself ! You may also want to check out Itzik's articles on http://www.winnetmag.com/SQLServer/ or subscribe to the printed version! His (and Tom's) book at: http://search.barnesandnoble.com/boo...sbn=1893115828 is certainly one for every bookshelf and there are many others! A more comprehensive list can be found at: http://www.aspfaq.com/show.asp?id=2423 John "Michael Vardinghus" <michaelvardinghus (AT) notexisting (DOT) com> wrote in message news:uWsJ41TTEHA.3548 (AT) TK2MSFTNGP09 (DOT) phx.gbl... Didn't think i could join like that...wouw... And I couldn't aggree more....would avoid cursors if possible - didn't think i could join... \Michael V "John Bell" <jbellnewsposts (AT) hotmail (DOT) com> skrev i en meddelelse news:uQgeIwTTEHA.4048 (AT) TK2MSFTNGP12 (DOT) phx.gbl... Hi How about: select p.*, l.titel from dbo.finansbudgetposter_staging p JOIN dbo.led1sortering l ON p.delregnskab = l.delregnskab and p.sagsbudget >= l.frasag and p.sagsbudget <= l.tilsag order by l.delregnskab, l.frasag, l.tilsag, l.titel A single result set will make the code that processes the results easier! John "Michael Vardinghus" <michaelvardinghus (AT) notexisting (DOT) com> wrote in message news:uZLZNpMTEHA.2416 (AT) TK2MSFTNGP09 (DOT) phx.gbl... Think i got it solved by this - seems to work okay...i'm not updating in this example - so the select will be replaced with an update sentence USE um_dw_finance_staging DECLARE @delregnskab int, @frasag int , @tilsag int, @titel varchar (40) DECLARE led1_cursor CURSOR FOR SELECT delregnskab, frasag, tilsag, titel FROM led1sortering order by delregnskab, frasag, tilsag, titel OPEN led1_cursor FETCH NEXT FROM led1_cursor into @delregnskab, @frasag, @tilsag, @titel WHILE @@FETCH_STATUS = 0 BEGIN select *, @titel from dbo.finansbudgetposter_staging post where post.delregnskab = @delregnskab and post.sagsbudget >= @frasag and post.sagsbudget <= @tilsag FETCH NEXT FROM led1_cursor into @delregnskab, @frasag, @tilsag, @titel END CLOSE authors_cursor DEALLOCATE authors_cursor GO "Michael Vardinghus" <michaelvardinghus (AT) notexisting (DOT) com> skrev i en meddelelse news:%23RkbWCMTEHA.3608 (AT) TK2MSFTNGP11 (DOT) phx.gbl... How would one go about doing this: Table 1: DimA Type FromDimB ToDimB 123 A 1 2 456 B 1 2 789 C 3 8 Table 2: DimB Type DimA 1 A 123 2 A 123 2 B 456 3 C 789 4 C 789 5 C 789 For now there is no DimA column in table 2 so I have to make this either by joining or cursor ? What would be the best approach - making a cursor on Table 1 and updatering table 2 in steps ? \Michael Vardinghus |
#9
| |||
| |||
|
|
Hi I assume that is the Ken Henderson book? I have it, but haven't read it either!!!! He is apparently producing a boxed set http://search.barnesandnoble.com/boo... 287509&itm=8, but I may wait for the directors cut DVD with extra bits ![]() John "Michael Vardinghus" <michaelvardinghus (AT) notexisting (DOT) com> wrote in message news:eX6wPpUTEHA.2580 (AT) TK2MSFTNGP12 (DOT) phx.gbl... Actually bougth sql for gurus....perhaps i should try to read it... ![]() "John Bell" <jbellnewsposts (AT) hotmail (DOT) com> skrev i en meddelelse news:uIHEkaUTEHA.1472 (AT) TK2MSFTNGP09 (DOT) phx.gbl... Hi Time spent reading books online will repay itself ! You may also want to check out Itzik's articles on http://www.winnetmag.com/SQLServer/ or subscribe to the printed version! His (and Tom's) book at: http://search.barnesandnoble.com/boo...sbn=1893115828 is certainly one for every bookshelf and there are many others! A more comprehensive list can be found at: http://www.aspfaq.com/show.asp?id=2423 John "Michael Vardinghus" <michaelvardinghus (AT) notexisting (DOT) com> wrote in message news:uWsJ41TTEHA.3548 (AT) TK2MSFTNGP09 (DOT) phx.gbl... Didn't think i could join like that...wouw... And I couldn't aggree more....would avoid cursors if possible - didn't think i could join... \Michael V "John Bell" <jbellnewsposts (AT) hotmail (DOT) com> skrev i en meddelelse news:uQgeIwTTEHA.4048 (AT) TK2MSFTNGP12 (DOT) phx.gbl... Hi How about: select p.*, l.titel from dbo.finansbudgetposter_staging p JOIN dbo.led1sortering l ON p.delregnskab = l.delregnskab and p.sagsbudget >= l.frasag and p.sagsbudget <= l.tilsag order by l.delregnskab, l.frasag, l.tilsag, l.titel A single result set will make the code that processes the results easier! John "Michael Vardinghus" <michaelvardinghus (AT) notexisting (DOT) com> wrote in message news:uZLZNpMTEHA.2416 (AT) TK2MSFTNGP09 (DOT) phx.gbl... Think i got it solved by this - seems to work okay...i'm not updating in this example - so the select will be replaced with an update sentence USE um_dw_finance_staging DECLARE @delregnskab int, @frasag int , @tilsag int, @titel varchar (40) DECLARE led1_cursor CURSOR FOR SELECT delregnskab, frasag, tilsag, titel FROM led1sortering order by delregnskab, frasag, tilsag, titel OPEN led1_cursor FETCH NEXT FROM led1_cursor into @delregnskab, @frasag, @tilsag, @titel WHILE @@FETCH_STATUS = 0 BEGIN select *, @titel from dbo.finansbudgetposter_staging post where post.delregnskab = @delregnskab and post.sagsbudget >= @frasag and post.sagsbudget <= @tilsag FETCH NEXT FROM led1_cursor into @delregnskab, @frasag, @tilsag, @titel END CLOSE authors_cursor DEALLOCATE authors_cursor GO "Michael Vardinghus" <michaelvardinghus (AT) notexisting (DOT) com> skrev i en meddelelse news:%23RkbWCMTEHA.3608 (AT) TK2MSFTNGP11 (DOT) phx.gbl... How would one go about doing this: Table 1: DimA Type FromDimB ToDimB 123 A 1 2 456 B 1 2 789 C 3 8 Table 2: DimB Type DimA 1 A 123 2 A 123 2 B 456 3 C 789 4 C 789 5 C 789 For now there is no DimA column in table 2 so I have to make this either by joining or cursor ? What would be the best approach - making a cursor on Table 1 and updatering table 2 in steps ? \Michael Vardinghus |
![]() |
| Thread Tools | |
| Display Modes | |
| |