2017-10-11 88 views

回答

0

希望您正在尋找交叉通過加入與爲了沿着 SQL功能。

Declare @table1 table (id int,employee nvarchar(max),Month0 nvarchar(max)) 
Declare @table2 table (Month0 nvarchar(max)) 

insert into @table1 
values(1,'rick',null) 

insert into @table1 
values(2,'tom',null) 

insert into @table1 
values(3,'John',null) 

insert into @table2 
values('Jan') 

insert into @table2 
values('Feb') 

insert into @table2 
values('Mar') 

select * from @table1 

select * from @table2 

select id,employee,b.Month0 from @table1 as a cross join @table2 as b order by id 

輸出中獲得:Output Obtained after executing sample query

+0

感謝您的快速回復,結果集是所有我需要的,但我需要表1(在上面的例子),結果通過消除所有空值更新,請建議如何實現這一點。 – ArK

+0

你沒有提到關於更新table1的任何內容,或者說你的問題與你在評論 –

+0

中提到的要求不太清楚,請查看SQL中的CRUD操作,JOINS,dbms中的規範化, –

相關問題