Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Best Choice : ¿Cursor or 2 Store Procedures?

Author  Topic 

calinzt
Starting Member

1 Post

Posted - 2009-04-15 : 16:32:26
Hi, i have a problem when a create a consultarion in a SP, because one field return more one data from other table(Profesion) while select return one data for each field

This is SP:

CREATE PROCEDURE beneficiado_listarAtencionUsuarioFecha
@usuario char(20),
@desde datetime,
@hasta datetime

AS
SELECT
beneficiado.fecha,
beneficiado.horaIngreso,
beneficiado.rut,beneficiado.usuario,
intranet.dbo.profesion.nombre as profesionNombre,
intranet.dbo.logueo.nombre as usuarioNombre,
intranet.dbo.logueo.apellido as usuarioApellido,
intranet.dbo.contribuyente.nombre as Nombre, intranet.dbo.contribuyente.apellido as apellido,
intranet.dbo.contribuyente.telefono as telefono,
intranet.dbo.contribuyente.celularCod as celularCod,
intranet.dbo.contribuyente.celular as celular

from beneficiado
Left Outer Join intranet.dbo.contribuyente on intranet.dbo.contribuyente.rut = beneficiado.rut

Left Outer Join intranet.dbo.logueo on intranet.dbo.logueo.iid = beneficiado.usuario

Left Outer Join intranet.dbo.profesion on intranet.dbo.profesion.ID = (select profesion from beneficiadoProfesion where usuario = @usuario AND fechaIngreso >= @desde AND fechaIngreso<= @hasta ) (*aqui devuelve mas de un valor)

WHERE beneficiado.usuario = @usuario
AND beneficiado.fecha >= @desde AND beneficiado.fecha<= @hasta
ORDER BY beneficiado.fecha
GO

My Question is:
¿what is the best performance?
¿cursor and sp or two SP, one without field profesion and another with only that field or concatenate?

I hear more Idea.

thax.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-05-12 : 10:04:52
We can't decidef or you wether or not the concatenate the professions.


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -