Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server SQL插入语法_Sql Server_Date_Insert_Int_Operand - Fatal编程技术网

Sql server SQL插入语法

Sql server SQL插入语法,sql-server,date,insert,int,operand,Sql Server,Date,Insert,Int,Operand,很抱歉,如果这是一个有点低的水平,但我是一名学生,在SQLServerManagementStudio上学习SQL,并试图向数据库添加一些虚拟数据,我正在使用以下命令 INSERT INTO dbo.Bookings (bookingid ,bookingdate ,customerid ,airportid ,outboundflight ,dateout ,timeout ,location ,inboundflight ,datein ,timein) VALUES (1, 201602

很抱歉,如果这是一个有点低的水平,但我是一名学生,在SQLServerManagementStudio上学习SQL,并试图向数据库添加一些虚拟数据,我正在使用以下命令

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 )
但我收到了以下错误消息:

信息:
操作数类型冲突:int与日期不兼容

所以我检查了数据库,这是结构的打印输出

       (<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)>
(
,
,
,
,
,
,
,
,
,
,
)

正如您所看到的,我试图添加日期的日期列中没有一个是int,事实上只有一个int,应该包含“2”

有谁能让我摆脱痛苦,因为我已经两天(断断续续地)在没有作业的情况下试图理解/解决这个问题,作业到期日迫在眉睫

谢谢你错过了这些引语

试一试

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

缺少引号

试一试


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

您必须为以下数据类型
日期提供引号

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 )

您必须在以下内容中为数据类型
日期
提供引号
'

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 )

将您的行复制到查询中,这就是我得到的!Msg 206,16级,状态2,第4行操作数类型冲突:int与time不兼容实际上理解速度有点慢,但您的答案修复了第一个错误,如date,但随后抛出了下一个错误,即time,因此我按照您缺少的引号回答在日期前后添加了它们,然后成功了(尽管时间格式似乎也不正确)但是我现在在那个表中有一行-非常感谢。将您的行复制到查询中,这就是我得到的!Msg 206,16级,状态2,第4行操作数类型冲突:int与time不兼容实际上理解有点慢,但您的答案修复了第一个错误,如date,但随后抛出了下一个错误,即time,因此我Allowed your missing quotes答案在日期前后添加了它们,然后就成功了(尽管时间格式似乎也不正确)但是我现在有一行在那张表中-非常感谢。David,检查出了那一行,这似乎是不同的,因为它是关于date和int之间输入类型的冲突,尽管我看不出冲突在哪里,因为唯一一个int列是第三列,应该有2个输入,正如我在问题中所说的。David,检查了one out和这似乎是不同的,因为它是关于日期和int之间输入类型的冲突,虽然我看不出冲突在哪里,因为唯一的int列是第三列,应该有2个输入,正如我在问题中所说的。