April 25, 2012

sp_help_datatype_mapping (Transact-SQL MetaData) Definition

Please note: that the following source code is provided and copyrighted by Microsoft and is for educational purpose only.
The meta data is from an SQL 2012 Server.

I have posted alot more, find the whole list here.

Goto Definition or MetaData

Definition:

sys.sp_help_datatype_mapping(nvarchar @dbms_name
, nvarchar @dbms_version
, nvarchar @sql_type
, int @source_prec)

MetaData:

 create procedure sys.sp_help_datatype_mapping  
(
@dbms_name sysname,
@dbms_version sysname = NULL,
@sql_type sysname = '%',
@source_prec int = NULL
)
as
set nocount on

-- Prepare dbms for case insensitive searches
SET @dbms_name = UPPER(@dbms_name)

SELECT source_type as [sql_type],
source_length_min as [sql_len_min],
source_length_max as [sql_len_max],
source_precision_min as [sql_prec_min],
source_precision_max as [sql_prec_max],
source_scale_min as [sql_scale_min],
source_scale_max as [sql_scale_max],
source_nullable as [sql_nullable],
source_createparams as [sql_createparams],
destination_type as [dest_type],
destination_length as [dest_len],
destination_precision as [dest_prec],
destination_scale as [dest_scale],
destination_nullable as [dest_nullable],
destination_createparams as [dest_createparams],
dataloss as [dataloss]
FROM sys.fn_helpdatatypemap
(
N'MSSQLSERVER',
'%',
@sql_type,
@dbms_name,
'%',
'%',
0
)
WHERE source_dbms = 'MSSQLSERVER' collate database_default
AND source_version IS NULL
AND destination_dbms = @dbms_name collate database_default
AND ((destination_version = @dbms_version) OR (@dbms_version IS NULL AND destination_version IS NULL))
AND source_type like @sql_type collate database_default
ORDER BY source_type, destination_type

No comments:

Post a Comment

Total Pageviews