Link to home
Create AccountLog in
Avatar of JonMny
JonMny

asked on

query performance

can anyone tell me a better way to do this

I have a table where they have

client l1 l2 l3 l4 l5 l6 up to l50

I need the results like

client l1
client l2


I did with a union but seems slow any thoughts?
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

UNION or UNPIVOT would be the way I would do it.

Of course, setting up the table that way in the first place was a bad idea :)
I did with a union but seems slow any thoughts?
As suggested previously, if it is too slow consider designing the table correctly.
Avatar of JonMny
JonMny

ASKER

not possible to redesign table. Legacy system.
In your procedure, create a temp table that is designed correctly and pre-determine what goes into that table before you do any querying of the data. This narrows your result set before you start smashing your SQL Server memory with high traffic. With it being a temporary table as well it will re-direct a lot of the processing onto tempdb.
ASKER CERTIFIED SOLUTION
Avatar of deighton
deighton
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
not possible to redesign table. Legacy system.
Then you are in for a rough ride.
Avatar of JonMny

ASKER

oh I know, the funny part is they want to buy this code....