I have a question about inserting column stored procedure into table.
I have two tables about 100 rows and 1 Mil rows.
Basically, I have a function that returns int comparing two data from different table.
And I want to run function on each combination of data.
Table 1 (~100 rows)
Col1
A
B
C
D
Table 2 (~1 Mil rows)
Col1
1
2
3
4
function(i,j) where i is from table 1 and j is from table 2
Code in nutshell is like:
while i < count(*) table 1
print i
while j < count(*) table 2
select function(i,J)
J = J + 1
end
i = i + 1
j = 0
end
The result display is a long single column with i (from table1) and int evaluated from function.
i(1)
1
3
4
.
.
.
i(2)
1
2
.
.
I want to display the above result like table dynamically assign column name to i.
i(1) i(2) i(3) .....
1 1 5
3 2 9
4 3 4
Thanks in advance.
This would be my solution:
You can check out a working example of this here on SEDE.
Edit
And just for clarification, you would replace t1 and t2 with the actual names of your 2 tables. Also in the SEDE example I just added
iandjtogether (t1.i + t2.j as functionResult) because I can’t create functions on there, but you would just call your function instead like I show in my answer (yourFunction(t1.i, t2.j) as functionResult).