简体   繁体   中英

What is wrong here for me to get this error message in Microsoft SQL Server?

My table structure:

我的桌子

My query:

insert into dbo.booking ([Member ID], [Court ID], [Date], [Timeslot], Price)  
values (1, 1, '2019-12-19', '07:00 - 17:00', N'Morning £12 + 2')

select * from dbo.booking

Then the error message:

Msg 242, Level 16, State 3, Line 1
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.

Does anyone know what I'm doing wrong here to get that error message?

You need to change timeslot , because a single datetime column cannot contain a range of times.

One idea is a string -- because that is what you are inserting. Another would be to have two columns, say timeslot_from and timeslot_to .

Then, when that is fixed, you can address price .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM