2013-11-24 106 views
0

我正在使用SQL Server 2008 R2。我怎樣才能得到所提供的輸出?在查詢中組合兩個表

tbl_Configure

Date  Name 
1/1/13  Sandeep 
1/2/13  Sudeep 

tbl_Install

Date  Name 
1/1/13  Sandeep 
1/2/13  Sandeep 

輸出:

Date  Name  Type 
1/1/13  Sandeep  Configure 
1/1/13  Sandeep  Install 
1/2/13  Sudeep  Configure 
1/2/13  Sandeep  Install 
+0

從你那裏塔基ng「Type」列 –

+0

@Suganthan如果我猜對了,它看起來像是來自表的名字 – Pepe

+0

@Suganthan'type'列就像下面Pepe回答的行的指示符。 –

回答

3
Select config.Date, config.Name, 'Configure' as Type From tbl_Configure config 
Union 
Select install.Date, install.Name, 'Install' as Type From tbl_Install install