我正在尝试从 select 语句中插入表,并向行添加其他参数,例如-
SELECT
Appt_ID,
Pracitioner_ID,
Appt_Book_ID,
Start_Time,
UR_NO,
[Type],
[Description]
FROM @TempWaiting,
@EndTime,
@PatientID,
@Title,
@FirstName,
@LastName,
@Surname,
@DOB
INTO PS_WAITING_LIST(Appt_ID,
Pracitioner_ID,
Appt_Book_ID,
Start_Time,
UR_NO,
[Type],
[Description],
End_Time,
Patient_ID,
Title,
First_Name,
Middle_Name,
Surname,
DOB)
这是在一个存储过程中,它说的只是 INTO 之后的错误。
我还尝试将其重写为-
insert into PS_WAITING_LIST (
Appt_ID,
Pracitioner_ID,
Appt_Book_ID,
Start_Time,
UR_NO,
[Type],
[Description],
End_Time,
Patient_ID,
Title,
First_Name,
Middle_Name,
Surname,
DOB)
SELECT
Appt_ID,
Pracitioner_ID,
Appt_Book_ID,
Start_Time,
UR_NO,
[Type],
[Description]
FROM @TempWaiting,
@EndTime,
@PatientID,
@Title,
@FirstName,
@LastName,
@Surname,
@DOB
这会引发错误,说明选择值的数量必须与插入列的数量匹配。很明显,事实并非如此。
我也试过插入表(col1,col2..)Select * from(select(...),col3,col9)