Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_add_datatype_mapping

  No additional text.


Syntax


-- Backwards compatible sp:
-- Use old sp_add_datatype_mapping to create a new
-- call to sp_MSrepl_adddatatypemapping.
-- This sp always maps MS SQL Server to a target DBMS.

create procedure sys.sp_add_datatype_mapping
(
    @dbms_name          sysname,
    @sql_type           sysname,
    @dest_type          sysname,
    @dest_prec          int,
    @dest_create_params int,
    @dest_nullable      bit
)
as
BEGIN
	DECLARE @dest_length	bigint
	DECLARE @dest_precision	bigint
	DECLARE @dest_scale		int

	SELECT	@dest_length	= NULL,
			@dest_precision	= NULL,
			@dest_scale		= NULL

    set nocount on

    if @dbms_name is null
    BEGIN
        RAISERROR (14043, 16, -1, '@dbms_name', 'sp_add_datatype_mapping')
        RETURN (1)
    END

    if @sql_type is null
    BEGIN
        RAISERROR (14043, 16, -1, '@sql_type', 'sp_add_datatype_mapping')
        RETURN (1)
    END

    if @dest_type is null
    BEGIN
        RAISERROR (14043, 16, -1, '@dest_type', 'sp_add_datatype_mapping')
        RETURN (1)
    END

    if @dest_prec is null
    BEGIN
        RAISERROR (14043, 16, -1, '@dest_prec', 'sp_add_datatype_mapping')
        RETURN (1)
    END

    if @dest_create_params is null
    BEGIN
        RAISERROR (14043, 16, -1, '@dest_create_params', 'sp_add_datatype_mapping')
        RETURN (1)
    END

    if @dest_nullable is null
    BEGIN
        RAISERROR (14043, 16, -1, '@dest_nullable', 'sp_add_datatype_mapping')
        RETURN (1)
    END

	-- Use create params to determine what the source / destination
	-- settings should be
	
	IF (@dest_create_params & 1) = 1
	BEGIN
		-- Precision
		SET @dest_precision = @dest_prec
	END
	
	IF ((@dest_create_params & 4) = 4) OR (@dest_create_params = 0)
	BEGIN
		-- Length
		SET @dest_length = @dest_prec
	END
	
	IF (@dest_create_params & 2) = 2
	BEGIN
		-- Scale
		SET @dest_scale = 0
	END

	-- Add data type mapping
	exec sp_MSrepl_adddatatypemapping	@source_dbms				= 'MSSQLSERVER',
										@source_version				= NULL,
										@source_type				= @sql_type,
										@destination_dbms			= @dbms_name,
										@destination_version		= NULL,
										@destination_type			= @dest_type,
										@destination_length			= @dest_length,
										@destination_precision		= @dest_precision,
										@destination_scale			= @dest_scale,
										@destination_nullable		= @dest_nullable,
										@destination_createparams	= @dest_create_params

    if @@error <> 0
        return(1)
END

 
Last revision 2008RTM
See also

  sp_MSdrop_replcom (Procedure)
sp_MSrepl_subdatatypemappings (Procedure)
       



News

  Query a named instance
Sybase+ASE+silent+install
SQL 2008 R2
Deprecated procedures in SQL2008
Reporting Services item-level role definitions
Create all your missing indexes
Converting datetime field
Start MSSQL Server Profiler at time
Replicating MSSQL Server views
Exploring Microsoft Sharepoint
The OLE DB provider "SQLNCLI10" for linked server indicates.
Mobile solar charger
Oracle to SQL Server replication
Cannot insert the value NULL into column
Undocumented Microsoft SQL Server 2008
VMware
Zoekmachine optimalisatie
SQL Servers hidden objects
FckEditor
Flash in Ajax
De hype die AJAX heet
Barcode scannen
MySQL; Gratis, makkelijk en snel!
PHP
sIFR; de combinatie tussen HTML en Flash