Sorry for not explaining the question well. Many want to know what it is for: It is for a cost calculation report for a manufactured item, the costs are calculated from the lowest level and are added to the highest level. What happens is that I develop this solution but I have it in Excel VBA, and I'm using memory arrays. Now I want to port to SQL. I do not know how to attach a spreadsheet. It is for a fruit punch (imaginary) because by company policies I can not use real values :-( I am showing 2 levels, but they can be up to 10. Example:
Nivel(1)=0 CostoTotal(1)=0 Articulo(1)="A0" Descripcion(1)="Bebida sabor Ponche" Cantidad(1)=1 Fuente(1)="Final" Tipo(1)=" " Costo(1)=
Nivel(2)=1 CostoTotal(2)=0 Articulo(2)="B1" Descripcion(2)="Recipiente de Plastico" Cantidad(2)=1 Fuente(2)="Comprado" Tipo(2)="M" Costo(2)=5
Nivel(3)=1 CostoTotal(3)=0 Articulo(3)="C1" Descripcion(3)="Tapa de Plastico" Cantidad(3)=1 Fuente(3)="Comprado" Tipo(3)="M" Costo(3)=1
Nivel(4)=1 CostoTotal(4)=0 Articulo(4)="D1" Descripcion(4)="Liquido" Cantidad(4)=1 Fuente(4)="SubNivel" Tipo(4)="M" Costo(4)=
Nivel(5)=2 CostoTotal(5)=0 Articulo(5)="E2" Descripcion(5)="Azucar" Cantidad(5)=0.1 Fuente(5)="Comprado" Tipo(5)="M" Costo(5)=20
Nivel(6)=2 CostoTotal(6)=0 Articulo(6)="F2" Descripcion(6)="Otros - No se suman" Cantidad(6)=1 Fuente(6)="Comprado" Tipo(6)="O" Costo(6)=10
Nivel(7)=2 CostoTotal(7)=0 Articulo(7)="G2" Descripcion(7)="Manzana" Cantidad(7)=0.1 Fuente(7)="Comprado" Tipo(7)="M" Costo(7)=100
Nivel(8)=2 CostoTotal(8)=0 Articulo(8)="H2" Descripcion(8)="Pera" Cantidad(8)=0.1 Fuente(8)="Comprado" Tipo(8)="M" Costo(8)=80
Nivel(9)=2 CostoTotal(9)=0 Articulo(9)="I2" Descripcion(9)="Agua" Cantidad(9)=0.1 Fuente(9)="Comprado" Tipo(9)="M" Costo(9)=10
Add the costs of level 2 and empty them in level 1, then calculate the costs of level 1 and empty them to level 0, and this is the final cost.
Is there any way to save the result of an SQL server query on variables? As an example: In Basic, you can do something like:
dim Control(100)
dim Fruta(100)
y puedo llenar las variable así:
Control(1)=1
Fruta(1)="Manzana"
Control(2)=2
Fruta(2)="Pera"
... hasta 100
Is it possible to do this using a SQL server query?
select control, fruta from almacen
And that the result of the query is filling the values of the Control and Fruit variable?