Showing posts with label dear. Show all posts
Showing posts with label dear. Show all posts

Monday, March 26, 2012

Query


Dear All
I have a query is:-
select
A.AllocatorId,a.CustomTypeId,a.CustomId,a.ScopeTypeId,a.ScopeId,a.ActivityTy
peId,a.PriorityId
from allocation a
Out put is
AllocatorId CustomTypeId CustomId ScopeTypeId ScopeId ActivityTypeId
PriorityId
-- -- -- -- -- --
--
1 456 2 38 154 20
151
and Another Query for corresponding ids
select LookupID,LookupTypeID,DisplayValue
from lookup where LookupID in ('154','151','456',2)
Out put is
LookupID LookupTypeID DisplayValue
-- -- ----
151 63 Low
154 38 Select Few Compay
456 106 UserID
2 10 Kolkatta
Now i would like to have output like this:-
1 456 2 Kolkatta 38 154 Select Few Compay 20 151 Low
I am using one query for it:
Query is
select Y.AllocatorId,Y.CustomTypeId,Y.CustomId,l.displayvalue as
CustomIdvalue
,Y.ScopeTypeId,Y.ScopeId,Y.ScopeidValue,Y.ActivityTypeId,Y.PriorityId,Y.Prio
rityIdValue
from
(select
x.AllocatorId,x.CustomTypeId,x.CustomId,x.ScopeTypeId,x.ScopeId,x.ScopeidVal
ue,x.ActivityTypeId,
x.PriorityId, l.displayValue as PriorityIdValue
from
(select
A.AllocatorId,a.CustomTypeId,a.CustomId,a.ScopeTypeId,a.ScopeId,l.DisplayVal
ue as scopeidValue,
a.ActivityTypeId,a.PriorityId
from allocation a
left join lookup l
on l.LookupID=a.ScopeId and l.LookupTypeID =a.Scopetypeid) X
left join lookup l
on l.LookupID=x.PriorityId ) Y
left join lookup l
on l.LookupID=Y.CustomId
Now My question is:-
Is ther any other optimized way to get this output.
thank & regards
Manoj kumarThe main problem is that your schema design is not normalized. You have 3
different columns referencing the same table. The best way to improve this
would be to have a separate lookup table for each type of id. You would the
n
have a very simple query.
If you don't have control over the schema, I think your query is a good way
to do it.
The only alternative way that I can think of, which seems to look simpler
but would perform the same is something like (I'm a little at the
purpose of the lookuptypeid since you use it once and not other times, so I
am going to skip it) Hopefully this gives you an idea:
select a.AllocatorId,
a.CustomTypeId,
a.CustomId,
l3.displayvalue as CustomIdvalue,
a.ScopeTypeId,
a.ScopeId,
l1.DisplayValue as ScopeidValue,
a.ActivityTypeId,
a.PriorityId,
l2.DisplayValue as PriorityIdValue
from allocation a
left join lookup l1
on l1.LookupID=a.ScopeId
left join lookup l2
on l2.LookupID=a.PriorityId
left join lookup l3
on l3.LookupID=a.CustomId
HTH
"Manoj" wrote:

>
> Dear All
> I have a query is:-
> select
> A.AllocatorId,a.CustomTypeId,a.CustomId,a.ScopeTypeId,a.ScopeId,a.Activity
TypeId,a.PriorityId
> from allocation a
> Out put is
> AllocatorId CustomTypeId CustomId ScopeTypeId ScopeId ActivityTypeI
d
> PriorityId
> -- -- -- -- -- --
-
> --
> 1 456 2 38 154 20
> 151
> and Another Query for corresponding ids
> select LookupID,LookupTypeID,DisplayValue
> from lookup where LookupID in ('154','151','456',2)
> Out put is
> LookupID LookupTypeID DisplayValue
> -- -- ---
-
> 151 63 Low
> 154 38 Select Few Compay
> 456 106 UserID
> 2 10 Kolkatta
> Now i would like to have output like this:-
> 1 456 2 Kolkatta 38 154 Select Few Compay 20 151 Low
> I am using one query for it:
> Query is
> select Y.AllocatorId,Y.CustomTypeId,Y.CustomId,l.displayvalue as
> CustomIdvalue
> ,Y.ScopeTypeId,Y.ScopeId,Y.ScopeidValue,Y.ActivityTypeId,Y.PriorityId,Y.P
riorityIdValue
> from
> (select
> x.AllocatorId,x.CustomTypeId,x.CustomId,x.ScopeTypeId,x.ScopeId,x.ScopeidV
alue,x.ActivityTypeId,
> x.PriorityId, l.displayValue as PriorityIdValue
> from
> (select
> A.AllocatorId,a.CustomTypeId,a.CustomId,a.ScopeTypeId,a.ScopeId,l.DisplayV
alue as scopeidValue,
> a.ActivityTypeId,a.PriorityId
> from allocation a
> left join lookup l
> on l.LookupID=a.ScopeId and l.LookupTypeID =a.Scopetypeid) X
> left join lookup l
> on l.LookupID=x.PriorityId ) Y
> left join lookup l
> on l.LookupID=Y.CustomId
>
> Now My question is:-
> Is ther any other optimized way to get this output.
> thank & regards
> Manoj kumar
>

Friday, March 9, 2012

QA limitation or simply I am doing anything wrong?

Dear all,
I am trying do a autocontained select but on the results panel appears the
line cut off:
select 'insert into
cargaprocesos(idproceso,proceso,ruta,res
pfich,rutabak,estado,fechaultimacarg
a,nota,dts,repositorio,servdts,idaplicac
ion,duracionult,duracionrel,marcafnu
l,marcabak,horas,frecuencia,responsable,
dias,casoerror,servdesa,docu,marcaff
echa,ficherofecha,ficheronu
l,enespera,ana)
values(' + convert(char(2),idproceso) + ')'
from cargaprocesos where proceso in('ABS_RecuperarCajero')
As ouput:
----
----
----
--
-
insert into
cargaprocesos(idproceso,proceso,ruta,res
pfich,rutabak,estado,fechaultimacarg
a,nota,dts,repositorio,servdts,idaplicac
ion,duracionult,duracionrel,marcafnu
l,marcabak,horas,frecuencia responsable,dias,casoerror,servdesa,docu
,marcaff
e
(1 filas afectadas)
stopped in "marcaffe" field.
Does anyone has suffered any experience with that? Is customizable?
Regards,Change the below setting.
Tools --> Options --> Results --> Maximum Character Per column.
Roji. P. Thomas
Net Asset Management
http://toponewithties.blogspot.com
"Enric" <Enric@.discussions.microsoft.com> wrote in message
news:5619C2E7-B22F-4B59-AD0C-1FCF0B9595FD@.microsoft.com...
> Dear all,
> I am trying do a autocontained select but on the results panel appears the
> line cut off:
> select 'insert into
> cargaprocesos(idproceso,proceso,ruta,res
pfich,rutabak,estado,fechaultimacarga,no
ta
,dts,repositorio,servdts,idaplicacion,du
racionult,duracionrel,marcafnul,marcabak
,hor
as,frecuencia,responsable,dias,casoerror
,servdesa,docu,marcaffecha,ficherofecha,
fich
ero
nul,enespera,ana)
> values(' + convert(char(2),idproceso) + ')'
> from cargaprocesos where proceso in('ABS_RecuperarCajero')
>
> As ouput:
>
> ----
----
----
--
--
> insert into
> cargaprocesos(idproceso,proceso,ruta,res
pfich,rutabak,estado,fechaultimaca
rga,nota,dts,repositorio,servdts,idaplic
acion,duracionult,duracionrel,marcaf
nul,marcabak,horas,frecuencia
> responsable,dias,casoerror,servdesa,docu
,marcaffe
> (1 filas afectadas)
> stopped in "marcaffe" field.
> Does anyone has suffered any experience with that? Is customizable?
> Regards,|||Hi
The problem is with the buffer size:
just goto Tools > Options
on the 'Results' tab, change the maximum characters per column from 256 to
some 8000.
the u can see the expected result:
aslo modift the query as:
select 'insert into
cargaprocesos(idproceso,proceso,ruta,res
pfich,rutabak,estado,fechaultimacarg
a,nota,dts,repositorio,servdts,idaplicac
ion,duracionult,duracionrel,marcafnu
l,marcabak,horas,frecuencia,responsable,
dias,casoerror,servdesa,docu,marcaff
echa,ficherofecha,ficheronu
l,enespera,ana)
values(' + convert(char(2),idproceso) + ')'
from cargaprocesos where proceso in('ABS_RecuperarCajero') as [Result]
to avoid the - across 3 lines
please let me know if u have any questions
best Regards,
Chandra
http://chanduas.blogspot.com/
http://www.SQLResource.com/
---
"Enric" wrote:

> Dear all,
> I am trying do a autocontained select but on the results panel appears the
> line cut off:
> select 'insert into
> cargaprocesos(idproceso,proceso,ruta,res
pfich,rutabak,estado,fechaultimacarga,no
ta
,dts,repositorio,servdts,idaplicacion,du
racionult,duracionrel,marcafnul,marcabak
,hor
as,frecuencia,responsable,dias,casoerror
,servdesa,docu,marcaffecha,ficherofecha,
fich
ero
nul,enespera,ana)
> values(' + convert(char(2),idproceso) + ')'
> from cargaprocesos where proceso in('ABS_RecuperarCajero')
>
> As ouput:
>
> ----
----
----
--
--
> insert into
> cargaprocesos(idproceso,proceso,ruta,res
pfich,rutabak,estado,fechaultimaca
rga,nota,dts,repositorio,servdts,idaplic
acion,duracionult,duracionrel,marcaf
nul,marcabak,horas,frecuencia responsable,dias,casoerror,servdesa,docu
,marca
ffe
> (1 filas afectadas)
> stopped in "marcaffe" field.
> Does anyone has suffered any experience with that? Is customizable?
> Regards,|||Thanks a lot Roji
"Roji. P. Thomas" wrote:

> Change the below setting.
> Tools --> Options --> Results --> Maximum Character Per column.
> --
> Roji. P. Thomas
> Net Asset Management
> http://toponewithties.blogspot.com
>
> "Enric" <Enric@.discussions.microsoft.com> wrote in message
> news:5619C2E7-B22F-4B59-AD0C-1FCF0B9595FD@.microsoft.com...
ronul,enespera,ana)
--
>
>|||oops,
select 'insert into
cargaprocesos(idproceso,proceso,ruta,res
pfich,rutabak,estado,fechaultimacarg
a,nota,dts,repositorio,servdts,idaplicac
ion,duracionult,duracionrel,marcafnu
l,marcabak,horas,frecuencia,responsable,
dias,casoerror,servdesa,docu,marcaff
echa,ficherofecha,ficheronu
l,enespera,ana)
values(' + convert(char(2),idproceso) + ')' as [Result]
from cargaprocesos where proceso in('ABS_RecuperarCajero')
I made a mistake in the query
best Regards,
Chandra
http://chanduas.blogspot.com/
http://www.SQLResource.com/
---
"Chandra" wrote:

> Hi
> The problem is with the buffer size:
> just goto Tools > Options
> on the 'Results' tab, change the maximum characters per column from 256 to
> some 8000.
> the u can see the expected result:
>
> aslo modift the query as:
> select 'insert into
> cargaprocesos(idproceso,proceso,ruta,res
pfich,rutabak,estado,fechaultimacarga,no
ta
,dts,repositorio,servdts,idaplicacion,du
racionult,duracionrel,marcafnul,marcabak
,hor
as,frecuencia,responsable,dias,casoerror
,servdesa,docu,marcaffecha,ficherofecha,
fich
ero
nul,enespera,ana)
> values(' + convert(char(2),idproceso) + ')'
> from cargaprocesos where proceso in('ABS_RecuperarCajero') as [Result]
> to avoid the - across 3 lines
> please let me know if u have any questions
>
> --
> best Regards,
> Chandra
> http://chanduas.blogspot.com/
> http://www.SQLResource.com/
> ---
>
> "Enric" wrote:
>
ronul,enespera,ana)
--|||hi Chandra, thanks for your input but it doesn't works:
using as [result]
Servidor: mensaje 156, nivel 15, estado 1, l_nea 6
Incorrect syntax near the keyword 'as'.
"Chandra" wrote:

> Hi
> The problem is with the buffer size:
> just goto Tools > Options
> on the 'Results' tab, change the maximum characters per column from 256 to
> some 8000.
> the u can see the expected result:
>
> aslo modift the query as:
> select 'insert into
> cargaprocesos(idproceso,proceso,ruta,res
pfich,rutabak,estado,fechaultimacarga,no
ta
,dts,repositorio,servdts,idaplicacion,du
racionult,duracionrel,marcafnul,marcabak
,hor
as,frecuencia,responsable,dias,casoerror
,servdesa,docu,marcaffecha,ficherofecha,
fich
ero
nul,enespera,ana)
> values(' + convert(char(2),idproceso) + ')'
> from cargaprocesos where proceso in('ABS_RecuperarCajero') as [Result]
> to avoid the - across 3 lines
> please let me know if u have any questions
>
> --
> best Regards,
> Chandra
> http://chanduas.blogspot.com/
> http://www.SQLResource.com/
> ---
>
> "Enric" wrote:
>
ronul,enespera,ana)
--|||It's ok. Take care yourself,
"Chandra" wrote:

> oops,
> select 'insert into
> cargaprocesos(idproceso,proceso,ruta,res
pfich,rutabak,estado,fechaultimacarga,no
ta
,dts,repositorio,servdts,idaplicacion,du
racionult,duracionrel,marcafnul,marcabak
,hor
as,frecuencia,responsable,dias,casoerror
,servdesa,docu,marcaffecha,ficherofecha,
fich
ero
nul,enespera,ana)
> values(' + convert(char(2),idproceso) + ')' as [Result]
> from cargaprocesos where proceso in('ABS_RecuperarCajero')
> I made a mistake in the query
> --
> best Regards,
> Chandra
> http://chanduas.blogspot.com/
> http://www.SQLResource.com/
> ---
>
> "Chandra" wrote:
>
ronul,enespera,ana)
heronul,enespera,ana)
--