我正在使用 SQL Server Management Studio 2008 并编写以下查询
INSERT INTO Transaction (TransactionType, AccountID, HolderName, Amount, CurrDate)
VALUES ('Cash Withdrawal', '25', 'abc', '1000', 'abc');
表的脚本是
SELECT TOP 1000 [ID]
,[TransactionType]
,[AccountID]
,[HolderName]
,[Amount]
,[CurrDate]
FROM [ATMSoftware].[dbo].[Transaction]
和ID
是主键,自动递增。但是我在插入查询时遇到错误
Incorrect syntax near the keyword 'Transaction'.
请帮帮我
问候
最佳答案
Transaction
是 SQL Server 中的保留关键字。您需要将表名包含在 []
中以告诉 SQL Server 这是一个名称而不是关键字:
INSERT INTO [Transaction]
(TransactionType,AccountID,HolderName,Amount,CurrDate)
VALUES
('Cash Withdrawal','25','abc','1000','abc');
关于c# - 关键字 'Transaction' 附近的语法不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8692508/