Re: Problem ...

Re: Problem ...

 

  

You can do decodes to concatanate the d1 values if there is a fixed limit
number of comma delimited values. I think a

for aRow in ( select a, b, c, d from abc order by a, b, c, d)
do
--concatanate the d1 value, and insert if the {a, b, c}'s change
done
insert

loop will be much faster. I'm not sure what you're doing with temp tables.
People who cross tabulations out of SQL are happier :->

/Aaron


----- Original Message -----
From: "Kaustubh Puranik" <[Email Address Removed] "LazyDBA.com Discussion" <[Email Address Removed] Monday, March 29, 2004 11:49 AM
Subject: Problem ...


I am writing the stored procedure and I want to do something like this:

I have a table called "abc" and here is the sample data of table abc .

Columns ==> a b c d
=== === === ===
a a a a
a a a b
a a a c
b b b x
b b b y
b b b z

And I want the data in a following format in a different table.

Columns ==> a1 b1 c1 d1
=== === === ===
a a a a,b,c
b b b x,y,z

Is there any way to do above without using cursors; (using temp tables).
I have a large data and It is very slow with the cursors.

Anyidea?

Thanks in advance !!!
MS Sql Server LazyDBA home page