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 2005 Forums
 Transact-SQL (2005)
 Dynamic crosstab help

Author  Topic 

omega1983
Starting Member

40 Posts

Posted - 2009-11-25 : 09:09:48
I have the following temp variable table

DECLARE @ID TABLE
(

corekey numeric(13),
coreid char(10),
coretype char (10),
corecomm varchar(4000)
)

INSERT INTO @ID (corekey,coreid,corecomm)
SELECT corekey,coreid,corecomm
FROM dbo.core_table


Here is sample output
corekey coreid corecomm
1233 1111 northeast
1234 1111 southeast
1235 1233 west
1236 1254 west
One ID can have many corekeys. Each corekey commands its own detail line (see coreid 1111) I want the data to read this way
coreid corecomm1 corecomm2 corecomm3
1111 northeast southeast
1235 west
1236 west

I cannot hardcode the corecomm because there are too many of them. I need a dynamic crosstab or something similar. I am using SQL 2005. Can I accomplish this without having to write a complex cursor



visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-11-27 : 02:38:20
duplicate
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=136381
Go to Top of Page
   

- Advertisement -