C# 尝试将sql数据导入visual studio web表单数据库
我正在尝试导入以下数据:C# 尝试将sql数据导入visual studio web表单数据库,c#,sql-server,visual-studio,C#,Sql Server,Visual Studio,我正在尝试导入以下数据: INSERT INTO shifts (shift_id, shift_facility_id, shift_user_id, shift_start_time, shift_replacement, shift_request_replacement) VALUES (1, 57, '1', '2017-05-19 00:00:00.000000', NULL, NULL), (2, 57, '1', '2017-05-19 12:00:00.000000',
INSERT INTO shifts (shift_id, shift_facility_id, shift_user_id, shift_start_time, shift_replacement, shift_request_replacement) VALUES
(1, 57, '1', '2017-05-19 00:00:00.000000', NULL, NULL),
(2, 57, '1', '2017-05-19 12:00:00.000000', NULL, NULL),
(3, 57, '1', '2017-05-20 00:00:00.000000', NULL, NULL),
(4, 57, '1', '2017-05-20 12:00:00.000000', NULL, NULL),
(5, 57, '2', '2017-05-21 00:00:00.000000', NULL, NULL),
(62, 59, '6', '2017-05-19 00:00:00.000000', NULL, NULL),
(64, 60, '4', '2017-05-19 00:00:00.000000', NULL, NULL);
在以下数据库中:
(LocalDB)\MSSQLLocalDB
CREATE TABLE shifts (
shift_id int NOT NULL,
shift_facility_id int NOT NULL,
shift_user_id varchar(64) NOT NULL,
shift_start_time datetime NOT NULL,
shift_replacement varchar(64) DEFAULT NULL,
shift_request_replacement varchar(65) DEFAULT NULL
)
但我一直在犯错误
Conversion failed when converting date and/or time from character string.
我试图从查询本身中删除每个,
(它修复了以前的一个问题),但这次没有成功
错误由以下部分产生:
'2017-05-20 12:00:00.000000'
有人知道如何使此SQL查询可执行吗?只需执行以下操作:
INSERT INTO shifts (shift_id, shift_facility_id, shift_user_id, shift_start_time, shift_replacement, shift_request_replacement)
VALUES
(1, 57, '1', '2017-05-19 00:00:00', NULL, NULL),
(2, 57, '1', '2017-05-19 12:00:00', NULL, NULL),
(3, 57, '1', '2017-05-20 00:00:00', NULL, NULL),
(4, 57, '1', '2017-05-20 12:00:00', NULL, NULL),
(5, 57, '2', '2017-05-21 00:00:00', NULL, NULL),
(62, 59, '6', '2017-05-19 00:00:00', NULL, NULL)
(64, 60, '4', '2017-05-19 00:00:00', NULL, NULL);
您有一个
datetime
字段,您不需要比该字段更高的精度,因此在几分钟内您就可以了。。。或者将shift\u start\u time设置为datetime2
列。如果可以更改表结构…:)当然,但是问题中有一个创建表:)干杯,伙计!Mvp:D