INSERT INTO MonthlyFee(StudentID, ClassTypeID, Fee, MonthID,
[Year], IsDefaulter, FeeStatus, CreatedDate)
SELECT StudentID, ClassTypeID FROM ClassRollNo
我想设置以下值(主要是硬编码参数):MonthID 1,2015年,IsDefaulter FALSE,FeeStatus 0和CreatedDate GETDATE()。
答案 0 :(得分:0)
只需按照select
的顺序在同一column list
语句中对这些值进行硬编码。尝试使用此语法
INSERT INTO MonthlyFee
(StudentID,
ClassTypeID,
Fee,
MonthID,
[Year],
IsDefaulter,
FeeStatus,
CreatedDate)
SELECT StudentID,
ClassTypeID,
100, -- You missed
1,
2015,
'false',
0,
Getdate()
FROM ClassRollNo
注意:您错过了费用列,我有硬编码
答案 1 :(得分:0)
使用相同的查询和您描述的值:
INSERT INTO MonthlyFee(StudentID, ClassTypeID,Fee,MonthID,
[Year],IsDefaulter,FeeStatus,CreatedDate)
SELECT StudentID, ClassTypeID, 0, 1, 2015, 0, 0, GETDATE() FROM ClassRollNo
答案 2 :(得分:0)
试试这个:
INSERT INTO MonthlyFee(StudentID, ClassTypeID,MonthID,
[Year],IsDefaulter,FeeStatus,CreatedDate)
SELECT StudentID, ClassTypeID,1,2013,false,0,getdate() FROM ClassRollNo