我在执行下面的查询时遇到/
的问题。我尝试删除/
,然后它又给了我一个错误""""附近的语法错误。我对我的查询发生了什么感到困惑。提前致谢
INSERT INTO Workers (TransManual, TransType, EmpNo, EmpName, TransDate, ScanIn, ScanOut, Basic, Overtime, Total, Remarks, Ocassion, Reason, Adjustment)
SELECT
0 AS TransManual,
1 AS TransType,
EmpNo,
EmpName,
CONVERT(DATETIME, CONVERT(CHAR(10), GETDATE(), 103), 103) AS TransDate,
''N/A'' AS ScanIn,
''N/A'' AS ScanOut,
8 AS Basic,
0 AS Overtime,
8 AS Total,
'''' AS Remarks,
'''' AS Ocassion,
'''' AS Reason,
'''' AS Adjustment
FROM Employees
WHERE PayType = 1
AND Leave = 0
答案 0 :(得分:2)
N / A的每一侧都不需要2个单引号 - 1会这样做。 ''N/A''
应为'N/A'
。您的空单引号也应该是''
。如果您希望将单引号放入数据库记录中,那么您在单引号内使用2个单引号的唯一原因就是。
答案 1 :(得分:2)
我认为你在这里出错了
''N/A'' AS ScanIn,
''N/A'' AS ScanOut,
如果你想插入N/A
那么你应该把它写成
'N/A' AS ScanIn,
'N/A' AS ScanOut,