你能帮助我,在我的查询中发现错误,我需要花费数小时来解决这个错误,提前谢谢
sqlquery = "SELECT dbo.trans_queue.que_no, dbo.trans_step.step_remarks," _
& " dbo.office.office_name, dbo.transaction.trans_name," _
& " dbo.trans_queue.date_arrive, dbo.trans_queue.time_arrive" _
& " FROM dbo.trans_queue" _
& " INNER JOIN dbo.trans_step ON dbo.trans_queue.trans_step_Id = dbo.trans_step.trans_step_Id" _
& " INNER JOIN dbo.office ON dbo.trans_queue.office_Id = dbo.office.office_Id" _
& " INNER JOIN dbo.transaction ON dbo.trans_queue.trans_Id = dbo.transaction.trans_Id" _
& " WHERE dbo.office.office_Id = '" & Now_Office_ID & "'" _
& " ORDER BY dbo.trans_queue.time_arrive AND dbo.trans_queue.date_arrive"
错误总是告诉我 "交易'"
附近的语法不正确答案 0 :(得分:3)
很可能问题来自于您的表名 TRANSACTION 是Transact SQL中的保留字。用方括号中的单词替换查询中所有出现的事务:
sqlquery = "SELECT dbo.trans_queue.que_no, dbo.trans_step.step_remarks," _
& " dbo.office.office_name, dbo.[transaction].trans_name," _
& " dbo.trans_queue.date_arrive, dbo.trans_queue.time_arrive" _
& " FROM dbo.trans_queue" _
& " INNER JOIN dbo.trans_step ON dbo.trans_queue.trans_step_Id = dbo.trans_step.trans_step_Id" _
& " INNER JOIN dbo.office ON dbo.trans_queue.office_Id = dbo.office.office_Id" _
& " INNER JOIN dbo.[transaction] ON dbo.trans_queue.trans_Id = dbo.[transaction].trans_Id" _
& " WHERE dbo.office.office_Id = '" & Now_Office_ID & "'" _
& " ORDER BY dbo.trans_queue.time_arrive AND dbo.trans_queue.date_arrive"
答案 1 :(得分:0)
你的错误应该是使用你没有指定数据库的研究用词“transaction”,在Microsoft SQL SERVER中你应该使用:
dbo.[transaction].trans_name,