Ahmed Aekbj
Ahmed Aekbj

Reputation: 91

I want to insert date into my SQL Server database

Type of date : datetime2

INSERT INTO Event_test (date, Object, ASDU, IOA)
VALUES(10/07/2016 12:00:00.523, TMC1DEFCAL, 65, 408)

Syntax error near '12'

Upvotes: 0

Views: 66

Answers (2)

Justin
Justin

Reputation: 403

Use ISO format date with single quotes. It should work.

INSERT INTO Event_test (date, Object, ASDU, IOA) VALUES
    ('2016-10-07 12:00:00.523', 'TMC1DEFCAL', 65, 408);

Upvotes: 1

Gordon Linoff
Gordon Linoff

Reputation: 1269445

You need single quotes. I would also recommend ISO standard formats:

INSERT INTO Event_test (date, Object, ASDU, IOA)
    VALUES('2016-10-07T12:00:00.523', 'TMC1DEFCAL', 65, 408);

Single quotes are also needed for string values.

Upvotes: 2

Related Questions