Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello,
here is my short script in sql server 2000:
[b]Create Table #tmp(ID int,y_val char(30),...)
Insert Into #tmp
exec stored_procedure[/b]now my #tmp is filled with [u]214[/u] rows,
87 of them have the same ID value(when I use distinct x_val
on #tmp I get [u]87[/u] rows)my next step is to try to update another table for each row([u]214[/u] times)I have in the temporary table:
[b]Update x_table
set field_x =
Case When m1.ID is null Then m2.x_val
Else m1.ID + ',' + m2.x_val End
From x_table m1
Inner join #tmp m2
where m1.ID= m2.ID[/b]My problem is that the update action seems to run only 87 times and not 214 times as the number of rows in the #tmp table.
The m1.ID should have a value like this in the end: 25,27,30... for the rows with ID that exist more then once.
maybe this is more clearly sample:
#tmp table has rows like this:
[u]ID[/u] [u]val_1[/u] [u]val_2[/u]
1 25 26
1 42 31
2 55 25
3 60 30
Second table has this row:
[u]ID[/u] [u]val_1[/u] [u]val_2[/u]
1 42 31
2 55 25
3 60 30I want the update action run 4 times as the number of rows in the #tmp
so row with ID 1 in the second table will be update twice.
Thanks for your help, Gil

![]() |
Output File - Header Remo...
|
Excel Formula I can't fig...
|
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |