我正在尝试使用AWS数据库迁移服务(DMS)从S3填充SQL Server 2014表。我有以下S3架构:
{
"TableCount": "1",
"Tables": [
{
"TableName": "employee",
"TablePath": "public/employee/",
"TableOwner": "",
"TableColumns": [
{
"ColumnName": "Id",
"ColumnType": "INT8",
"ColumnNullable": "false",
"ColumnIsPk": "true"
},
{
"ColumnName": "HireDate",
"ColumnType": "TIMESTAMP"
},
{
"ColumnName": "Name",
"ColumnType": "STRING",
"ColumnLength": "20"
}
],
"TableColumnsTotal": "3"
}
]
}
当我运行迁移任务时,我收到以下溢出错误,因为SQL Server不允许将S3中的值2018-04-11 08:02:16.788027
插入到SQL Server DATETIME
列中。
我的问题是,有没有办法告诉AWS DMS在SQL Server中将TIMESTAMP
S3数据创建为DATETIME2
列? 注意:每次迁移运行时,都会删除并重新创建表。我可以通过在HireDate为DATETIME2
的SQL-Server中自己手动创建表来解决此问题,然后设置DMS迁移'目标表准备模式'到TRUNCATE
而不是放弃/创建,但这对我目前的解决方案并不理想。
[TARGET_LOAD ]E: Failed to execute statement: 'INSERT INTO [public].[employee]([Id],[HireDate],[Name]) values (?,?,?)' [1022502] (ar_odbc_stmt.c:2456)
[TARGET_LOAD ]E: RetCode: SQL_ERROR SqlState: 22008 NativeError: 0 Message: [Microsoft][ODBC Driver 13 for SQL Server]Datetime field overflow. Fractional second precision exceeds the scale specified in the parameter binding. Line: 1 Column: 4 [1022502] (ar_odbc_stmt.c:2462)
[TARGET_LOAD ]E: Invalid input for column 'HireDate' of table 'public'.'employee' in line number 1.(sqlserver_endpoint_imp.c:2357)
答案 0 :(得分:0)
解决方案是在S3模式中为"ColumnScale"
列指定timestamp
属性,这将确保将SQL Server目标列创建为DATETIME2(7)
,即
{
"TableCount": "1",
"Tables": [
{
"TableName": "employee",
"TablePath": "public/employee/",
"TableOwner": "",
"TableColumns": [
{
"ColumnName": "Id",
"ColumnType": "INT8",
"ColumnNullable": "false",
"ColumnIsPk": "true"
},
{
"ColumnName": "HireDate",
"ColumnType": "TIMESTAMP",
"ColumnScale": "7",
},
{
"ColumnName": "Name",
"ColumnType": "STRING",
"ColumnLength": "20"
}
],
"TableColumnsTotal": "3"
}
]
}