How to capture multiple fields returned from a Select using Stored Procedure with informed parameters and put inside variables using SqlServer?

1

- A dataset will be returned after informing 2 parameters, I need to get this dataset and put it in variables.

@TypeType VARCHAR (5), @cdVeiculo int

as

if (@ClienteTipoVeiculo='Moto')
begin

    Select  mm.nmMarcaMoto, mom.nmModeloMoto, v.Renavam, v.Placa, v.AnoFabricacao,
            v.AnoModelo, v.Obs

    From Cliente C, TipoVeiculo tv, Veiculo v, MarcaMoto mm, ModeloMoto mom

        Where v.Vei_cdCliente           = c.cdCliente 
                and v.Vei_cdMarca       = mm.cdMarca    
                and v.Vei_cdModelo      = mom.cdModeloMoto              
                and tv.nmTipoVeiculo    = @ClienteTipoVeiculo and v.cdVeiculo=@cdVeiculo

end
 else if (@ClienteTipoVeiculo='Carro')      

    Select  mc.nmMarcaCarro, moc.nmModeloCarro, v.Renavam, v.Placa,
            v.AnoFabricacao, v.AnoModelo, v.Obs

    From Cliente C, MarcaCarro mc, ModeloCarro moc, TipoVeiculo tv, Veiculo v

        Where v.Vei_cdCliente           = c.cdCliente 
                and v.Vei_cdMarca       = mc.cdMarca    
                and v.Vei_cdModelo      = moc.codigo 
                and tv.nmTipoVeiculo    = @ClienteTipoVeiculo and v.cdVeiculo=@cdVeiculo  


  else
    raiserror ('Valor informado só pode ser Carro ou Moto',14,2)
    
asked by anonymous 19.07.2018 / 19:00

0 answers