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.
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 datetimeASSELECTbeneficiado.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 celularfrom beneficiadoLeft Outer Join intranet.dbo.contribuyente on intranet.dbo.contribuyente.rut = beneficiado.rutLeft Outer Join intranet.dbo.logueo on intranet.dbo.logueo.iid = beneficiado.usuarioLeft 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 = @usuarioAND beneficiado.fecha >= @desde AND beneficiado.fecha<= @hastaORDER BY beneficiado.fechaGOMy 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" |
|
|
|
|
|
|
|