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 2000 Forums
 SQL Server Development (2000)
 Creating a new table columns from another table's rows

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-01-18 : 08:32:09
Tom writes "I have a lookup table with 2 columns and 3 rows:

HID Description
1 Hours
2 Travel
3 OnCall

This table will not change very often, but it may be dynamic.
I want to create another table that will have following columns:
ID Hours Travel [On Call]

Data will be populated from another table:
ID HID Number
1 1 1.5
1 2 30
1 3 2.5
2 1 6
3 1 7.5
3 3 30

So final result would be:
ID Hours Travel [On Call]
1 1.5 30 2.5
2 6 7.5 0
3 7.5 0 30

Can this be done using SQL Server stored procedures/functions/other? I don't need to modify data in this manner, I just want to retrieve it for reports.

Hope someone can help. I can probably do this in C# but I'd like to know if it's possible in SQL Server.

Thanks"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-01-18 : 08:34:33
See if these are helpful
http://sqljunkies.com/WebLog/amachanic/archive/2004/11/10/5065.aspx?Pending=true
http://weblogs.sqlteam.com/jeffs/archive/2005/05.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -