语句:IDENTITY(int, 1,1) as PPid
例如:将临时表1和临时表2中的数据插入到临时表3中,并在临时表三中新增一个自增字段。
select
IDENTITY(int, 1,1) as PPid
,#temp11.*
,#temp21.FlowingID
,#temp21.RecruiteID
,#temp21.ExamNum
,#temp21.ExamDate
,#temp21.ExamID
,#temp21.RecordID
,#temp21.SuveryState
,#temp21.Content
,#temp21.OperID
,#temp21.OperName
into #temp31
from
#temp11,
#temp21
where
#temp11.ID*=#temp21.RecruiteID
select
table1.ID as RecruiteID
,table1.Name
,table2.ExamNum
,convert(varchar(10),table2.ExamDate,120) as ExamDate
,table2.ExamID
,table2.RecordID
,table2.SuveryState
,table2.Content
,table2.OperID
,table2.OperName
from
#temp31 as table1
,#temp31 as table2
where
table1.PPID=table2.PPID