Rescatar data de un SP

03/11/2004 - 17:27 por Tonijua | Informe spam
Tenemos el sgte script de creación

create table A (cc int, x int , y int, z int)
create table B (cc int, x int , y int)
create table C (cc int, x int , y int, z int, w int)
go
insert into a values (1, 1, 1, 1)
insert into b values (1, 1, 1)
insert into c values (1, 1, 1, 1, 1)
go

y el sgte SP
Create procedure p1
(@cc int) as
begin
select * from a where cc = @cc
select * from b where cc = @cc
select * from c where cc = @cc
end

lo que da como resultado con @cc = 1
cc x y z
1 1 1 1


cc x y
1 1 1


cc x y z w
1 1 1 1 1


Hay alguna forma de rescatar esta información con una sola llamada al
procedimiento almacenamdo P1 en C# (con un SqlDataReader) sin necesidad de
realizar tres consultas independientes ??


Tonijua!!
 

Leer las respuestas

#1 qwalgrande
03/11/2004 - 17:41 | Informe spam
Hola.

No estoy seguro de haberte entendido bien, pero puedes usar selects de union:

select cc, x, y, z, null as w, 'a' as Tabla from a where cc = @cc
union all
select cc, x, y, null as z, null as w, 'b' as Tabla from b where cc = @cc
union all
select cc, x, y, z, w, 'c' as Tabla from c where cc = @cc

qwalgrande


"Tonijua" wrote:

Tenemos el sgte script de creación

create table A (cc int, x int , y int, z int)
create table B (cc int, x int , y int)
create table C (cc int, x int , y int, z int, w int)
go
insert into a values (1, 1, 1, 1)
insert into b values (1, 1, 1)
insert into c values (1, 1, 1, 1, 1)
go

y el sgte SP
Create procedure p1
(@cc int) as
begin
select * from a where cc = @cc
select * from b where cc = @cc
select * from c where cc = @cc
end

lo que da como resultado con @cc = 1
cc x y z
1 1 1 1


cc x y
1 1 1


cc x y z w
1 1 1 1 1


Hay alguna forma de rescatar esta información con una sola llamada al
procedimiento almacenamdo P1 en C# (con un SqlDataReader) sin necesidad de
realizar tres consultas independientes ??


Tonijua!!



Preguntas similares