Share via


sp_getdefaultdatatypemapping (Transact-SQL)

在 MicrosoftSQL 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_dbms 是 sysname,它可以是下列值之一。

    描述

    MSSQLSERVER

    來源是一個 SQL Server 資料庫。

    ORACLE

    來源是一個 Oracle 資料庫。

    您必須指定這個參數。

  • [@source_version= ] 'source_version'
    這是來源 DBMS 的版本號碼。source_version 是 varchar(10),預設值是 NULL。

  • [@source_type= ] 'source_type'
    這是來源 DBMS 中的資料類型。source_type 是 sysname,沒有預設值。

  • [@source_length= ] source_length
    這是來源 DBMS 中的資料類型長度。source_length 是 bigint,預設值是 NULL。

  • [@source_precision= ] source_precision
    這是來源 DBMS 中的資料類型有效位數。source_precision 是 bigint,預設值是 NULL。

  • [@source_scale= ] source_scale
    這是來源 DBMS 中的資料類型小數位數。source_scale 是 int,預設值是 NULL。

  • [@source_nullable= ] source_nullable
    這是指來源 DBMS 中的資料類型是否支援 NULL 值。source_nullable 是 bit,預設值是 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_precision 是 bigint,預設值是 NULL。

  • [@destination_scale= ] destination_scaleOUTPUT
    這是目的地 DBMS 中的資料類型小數位數。destination_scale 是 int,預設值是 NULL。

  • [@destination_nullable= ] destination_nullableOUTPUT
    這是指目的地 DBMS 中的資料類型是否支援 NULL 值。destination_nullable 是 bit,預設值是 NULL。1 表示支援 NULL 值。

  • [@dataloss= ] datalossOUTPUT
    這是指對應是否可能遺失資料。dataloss 是 bit,預設值是 NULL。1 表示可能遺失資料。

傳回碼值

0 (成功) 或 1 (失敗)

備註

sp_getdefaultdatatypemapping 用於 SQL Server 和非 SQL Server DBMS 之間的所有複寫類型中。

sp_getdefaultdatatypemapping 會傳回最符合指定來源資料類型的預設目的地資料類型。

權限

只有系統管理員 (sysadmin) 固定伺服器角色的成員,才能夠執行 sp_getdefaultdatatypemapping