Home
Microsoft SQL Server
  - System tables
  - Procedure
    - Change Data Capture
    - Constraints
    - Files & folders
    - Fulltext (EFTS)
    - Index
    - Login & Users
    - OleDb
    - Oracle
    - Replication
    - Scripting
    - Server
    - Spatial geo
    - SQL Server Agent
    - Transaction
    - Trigger
    - XML
    - Uncategorized
  - Views
    - DMV
  - Functions
DigiMailing
Contact
The name of the object you are looking for
sp_add_datatype_mapping

This is a procedure in the mssqlsystemresource database.
--
-- 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

Questions

Feel free to contact.
Email answer to
Question

Type this code
See also

sp_MSdrop_replcom (Procedure)
sp_MSrepl_subdatatypemappings (Procedure)

Nieuws

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