sp_getdefaultdatatypemapping (Transact-SQL)

适用于:SQL Server

返回有关 SQL Server 与非 SQL Server 数据库管理系统(DBMS)之间指定数据类型的默认映射的信息。 此存储过程在分发服务器上的任何数据库中执行。

Transact-SQL 语法约定

语法

sp_getdefaultdatatypemapping [ @source_dbms = ] 'source_dbms'
    [ , [ @source_version = ] 'source_version' ]
      , [ @source_type = ] 'source_type'
    [ , [ @source_length = ] source_length ]
    [ , [ @source_precision = ] source_precision ]
    [ , [ @source_scale = ] source_scale ]
    [ , [ @source_nullable = ] source_nullable ]
      , [ @destination_dbms = ] 'destination_dbms'
    [ , [ @destination_version = ] 'destination_version' ]
    [ , [ @destination_type = ] 'destination_type' OUTPUT ]
    [ , [ @destination_length = ] destination_length OUTPUT ]
    [ , [ @destination_precision = ] destination_precision OUTPUT ]
    [ , [ @destination_scale = ] destination_scale OUTPUT ]
    [ , [ @destination_nullable = ] source_nullable OUTPUT ]
    [ , [ @dataloss = ] dataloss OUTPUT ]
[ ; ]

参数

[ @source_dbms = ] 'source_dbms'

从中映射数据类型的 DBMS 的名称。 @source_dbmssysname,可以是以下值之一:

说明
MSSQLSERVER 源是 SQL Server 数据库。
ORACLE 源为 Oracle 数据库。

必须指定此参数。

[ @source_version = ] 'source_version'

源 DBMS 的版本号。 @source_version为 varchar(10),默认值为 NULL。

[ @source_type = ] 'source_type'

源 DBMS 中的数据类型。 @source_typesysname,没有默认值。

[ @source_length = ] source_length

源 DBMS 中数据类型的长度。 @source_length为 bigint,默认值为 NULL。

[ @source_precision = ] source_precision

源 DBMS 中数据类型的精度。 @source_precisionbigint,默认值为 NULL。

[ @source_scale = ] source_scale

源 DBMS 中数据类型的规模。 @source_scaleint,默认值为 NULL。

[ @source_nullable = ] source_nullable

指定源 DBMS 中的数据类型是否支持 NULL 值。 @source_nullable,默认值 1为 ,这意味着支持 NULL 值。

[ @destination_dbms = ] 'destination_dbms'

目标 DBMS 的名称。 @destination_dbms为 sysname,可以是以下值之一:

说明
MSSQLSERVER 目标为 SQL Server 数据库。
ORACLE 目标为 Oracle 数据库。
DB2 目标为 IBM DB2 数据库。
SYBASE 目标为 Sybase 数据库。

必须指定此参数。

[ @destination_version = ] 'destination_version'

目标 DBMS 的产品版本。 @destination_version为 varchar(10),默认值为 NULL。

[ @destination_type = ] 'destination_type' OUTPUT

目标 DBMS 中列出的数据类型。 @destination_type为 sysname,默认值为 NULL。

[ @destination_length = ] destination_length OUTPUT

目标 DBMS 中的数据类型的长度。 @destination_length为 bigint,默认值为 NULL。

[ @destination_precision = ] destination_precision OUTPUT

目标 DBMS 中的数据类型的精度。 @destination_precisionbigint,默认值为 NULL。

[ @destination_scale = ] destination_scale OUTPUT

目标 DBMS 中的数据类型的小数位数。 @destination_scaleint,默认值为 NULL。

[ @destination_nullable = ] destination_nullable OUTPUT

指定目标 DBMS 中的数据类型是否支持 NULL 值。 @destination_nullable为,默认值为 NULL。 1 表示支持 NULL 值。

[ @dataloss = ] dataloss OUTPUT

指定映射是否有可能丢失数据。 @dataloss,默认值为 NULL。 1 表示可能会丢失数据。

返回代码值

0(成功)或 1(失败)。

注解

sp_getdefaultdatatypemapping用于 SQL Server 与非 SQL Server DBMS 之间的所有类型的副本 (replica)。

sp_getdefaultdatatypemapping 返回与指定源数据类型最接近的默认目标数据类型。

权限

只有 sysadmin 固定服务器角色的成员才能执行sp_getdefaultdatatypemapping