关键字"交易"附近的语法不正确

Sna*_*ake 2 c# sql database sql-server-2005 sql-server-2008

我正在使用SQL Server Management Studio 2008并编写以下查询

INSERT INTO Transaction (TransactionType, AccountID, HolderName, Amount, CurrDate) 
VALUES ('Cash Withdrawal', '25', 'abc', '1000', 'abc');
Run Code Online (Sandbox Code Playgroud)

并且表的脚本是

SELECT TOP 1000 [ID]
      ,[TransactionType]
      ,[AccountID]
      ,[HolderName]
      ,[Amount]
      ,[CurrDate]
  FROM [ATMSoftware].[dbo].[Transaction]
Run Code Online (Sandbox Code Playgroud)

并且ID是主键并自动递增.但我在插入查询上收到错误

关键字"交易"附近的语法不正确.

请帮我

问候

Ode*_*ded 10

Transaction是SQL Server中的保留关键字.您需要将表名括[]起来告诉SQL Server它是一个名称而不是关键字:

INSERT INTO [Transaction] 
       (TransactionType,AccountID,HolderName,Amount,CurrDate) 
VALUES 
       ('Cash Withdrawal','25','abc','1000','abc');
Run Code Online (Sandbox Code Playgroud)


Tim*_*ora 8

Transaction是一个保留字.把它放在括号中.

INSERT INTO [Transaction](TransactionType, AccountID, HolderName, Amount, CurrDate) 
    VALUES ('Cash Withdrawal', '25', 'abc', '1000', 'abc');
Run Code Online (Sandbox Code Playgroud)

如有疑问,请将对象名称放在括号中.