Search code examples
sql-serverdateinsertintoperand

SQL INSERT INTO syntax


Sorry if this is a little low level but I am a student learning SQL on SQL Server management Studio and trying to add some dummy data to a database I am using the following

INSERT INTO dbo.Bookings (bookingid ,bookingdate ,customerid ,airportid ,outboundflight ,dateout ,timeout ,location ,inboundflight ,datein ,timein)

VALUES (1, 20160225, 2, 'STN', 'JJ2305', 20160316, 0950 , null, 'JJ2306', 20160416, 1800 )

But I am getting this error message :

Message: Operand type clash: int is incompatible with date

So I checked the db and this is a printout of the structure

       (<bookingid, nchar(10),>
       ,<bookingdate, date,>
       ,<customerid, int,>
       ,<airportid, nvarchar(5),>
       ,<outboundflight, nchar(10),>
       ,<dateout, date,>
       ,<timeout, time(7),>
       ,<location, nchar(10),>
       ,<inboundflight, nchar(10),>
       ,<datein, date,>
       ,<timein, time(7)>

)

As you can see non of the columns for dates that I am attempting to add a date to are int , in fact there is only one int and that should hold the '2'

Can anyone put me out of my misery as I have tried to understand/fix this for two days (off and on) without and assignment due date is looming !

Thanks


Solution

  • Missing the quotes.

    Try

    VALUES (1, '20160225', 2, 'STN', 'JJ2305', '20160316', 0950 , null, 'JJ2306', '20160416', 1800 )