0

Our erp has a table and the name is STOPLIST. When I try to insert records I get an error. Msg 156, Level 15, State 1, Line 1 Incorrect syntax near the keyword 'STOPLIST'. I think it's a reserved word. So, how do I insert to that?

INSERT INTO STOPLIST(PEOPLE_ID,STOP_REASON,STOP_DATE,CLEARED,CLEARED_DATE,COMMENTS,CREATE_DATE,CREATE_TIME,CREATE_OPID,CREATE_TERMINAL)
VALUES
('000092434','RGSA','2016-06-29 00:00:00.000','Y','2016-07-11 00:00:00.000',NULL,'2016-06-29 00:00:00.000','1900-01-01 11:12:05.227','LBARANJI',1)
Blocks
  • 351
  • 4
  • 12
  • 2
    Square brackets escape: `INSERT INTO [STOPLIST]( ...` – Alex K. May 30 '17 at 14:50
  • 3
    Possible duplicate of [How to deal with SQL column names that look like SQL keywords?](https://stackoverflow.com/questions/285775/how-to-deal-with-sql-column-names-that-look-like-sql-keywords) – GSerg May 30 '17 at 14:50

1 Answers1

1

You can use square brackets to escape reserved words. Change your code to use [STOPLIST]:

INSERT INTO [STOPLIST]
(
  PEOPLE_ID, 
  STOP_REASON, 
  STOP_DATE,
  CLEARED, 
  CLEARED_DATE, 
  COMMENTS, 
  CREATE_DATE, 
  CREATE_TIME, 
  CREATE_OPID, 
  CREATE_TERMINAL
)
VALUES
(
  '000092434',
  'RGSA',
  '2016-06-29 00:00:00.000',
  'Y',
  '2016-07-11 00:00:00.000',
  NULL,
  '2016-06-29 00:00:00.000',
  '1900-01-01 11:12:05.227',
  'LBARANJI',
  1
)
ollie
  • 1,009
  • 1
  • 8
  • 11