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 2008 Forums
 Transact-SQL (2008)
 Create view with multiple tables

Author  Topic 

dan963
Starting Member

3 Posts

Posted - 2012-04-29 : 12:31:05
Hi,
I have 3 tables and I'm trying to merge data from all 3 tables into a 2 column view and if anyone can help that would be great. I want the column names from Table B and Table C to be entered into the Field column in Table A and the rows from Table B and Table C to be entered into Table A's Value column.

Table A: (2 column field and value)

Details Value
ID 1
Employee No 123456
Leaving Date 01-05-2012
Leaving Reason 11

Table B: (2 columns)

ID Date Notified
1 01-04-2012

Table C: (a lookup table for Leaving Reason)

Id Detail
1 Early Retirement

All tables are joined by ID and I want to end up with a View:

Field Value
Employee No 12345
Leaving Date 01-05-2012
Leaving Reason Early Retirement
Date Notified 01-04-2012

Thanks
Dan

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-04-29 : 20:53:56
same as

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=174112

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -