我有这个脚本,它适用于 SQL Server 2012,但我需要在 SQL Server 2008 中使用它。有人有建议吗?
Create table #TempOne (ID int)
Insert into #TempOne
Values (1), (2), (34), (121), (72), (34), (81), (26), (234)
Create table #TempTwo
(
ID int,
Name Varchar(30),
Age int
)
Insert into #TempTwo
Values (18, 'P', 291), (11, 'P', 21), (13, 'P', 11), (21, 'P', 21)
Select
LEAD(ID,3) Over(Order By ID) As ID, Name , Age
From
(Select ID, NULL As Name, NULL As Age
From #TempOne
Union
Select NULL, Name, age
From #TempTwo) a