将varchar值'2014-03-07 10:48:06'转换为Sql中的数据类型int时转换失败

时间:2015-05-22 09:10:29

标签: sql sql-server

在下表中,我有一个表名UserGroupMapTable下面列出了列,当我插入它时它的数据类型会抛出错误

  

转换varchar值时转换失败'2014-03-07   10:48:06'到数据类型int

请帮我这样做。

Column Datatype
UserID  int
GroupID int
CreatedBy int
CreatedOn DateTime
ModifiedBy int
ModifiedOn Datetime



INSERT INTO UserGroupMapTable(UserID,GroupID,CreatedOn,CreatedBy,ModifiedBy,ModifiedOn) VALUES ((SELECT UserID FROM UserTable WHERE UserFirstName = 'Bhupinder'),(SELECT GroupID FROM GroupsTable WHERE GroupName = 'ReconciliationAdmin'),'2014-03-07 10:48:06' ,1,'2014-03-07 10:48:06',1)

1 个答案:

答案 0 :(得分:1)

更改插入列表中的订单ModifiedOnModifiedBy,如下所示

INSERT INTO UserGroupMapTable(UserID,GroupID,CreatedOn,CreatedBy,ModifiedOn,ModifiedBy) 
 VALUES ((SELECT UserID FROM UserTable WHERE UserFirstName = 'Bhupinder'),(SELECT GroupID FROM GroupsTable WHERE GroupName = 'ReconciliationAdmin'),'2014-03-07 10:48:06' ,1,'2014-03-07 10:48:06',1)