February 19, 2009 at 3:49 pm
Hello,
I was wondering if anyone knows how to insert data from
table A
[Country],
[State],
[ID],
[2008],
[2009],
[2010]
schema into
table B
[Country],
[State] ,
[ID],
[Year], -- being the column heading of 2008, 2009 or 2010
[YearValue], -- the data contained in column for the respective year
I'm a bit stuck on this one
Cheers 🙂
Remember
Without Change something sleeps inside of us that seldom awakens, the sleeper must awaken!!
February 19, 2009 at 3:58 pm
Investigate the UNPIVOT clause in Books Online.
February 19, 2009 at 3:58 pm
[font="Verdana"]Have you had a look at the UNPIVOT command on SQL Server Books Online? I suspect that would do what you want.[/font]
February 19, 2009 at 3:59 pm
Thanks for the heads up 🙂
Remember
Without Change something sleeps inside of us that seldom awakens, the sleeper must awaken!!
February 19, 2009 at 4:00 pm
Mr J (2/19/2009)
Hello,I was wondering if anyone knows how to insert data from
table A
[Country],
[State],
[ID],
[2008],
[2009],
[2010]
schema into
table B
[Country],
[State] ,
[ID],
[Year], -- being the column heading of 2008, 2009 or 2010
[YearValue], -- the data contained in column for the respective year
I'm a bit stuck on this one
Cheers 🙂
insert into dbo.tableB
select
[Country],
[State],
[ID],
2008,
[2008]
from
dbo.tableA
union all
select
[Country],
[State],
[ID],
2009,
[2009]
from
dbo.tableA
union all
select
[Country],
[State],
[ID],
2010,
[2010]
from
dbo.tableA
February 19, 2009 at 4:02 pm
Sweet very cool 😀
Remember
Without Change something sleeps inside of us that seldom awakens, the sleeper must awaken!!
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply