create procedure sys.sp_MSRecontructType (@type nvarchar(60) output,
@len smallint,
@prec int,
@scale int)
as
declare @typeout nvarchar(60)
select @typeout = @type
-- no need to add len/prec/scale for timestamp
-- append length or scale and precision if needed
if (@typeout = 'varbinary' or @typeout = 'varchar' or @typeout = 'nvarchar'
or @typeout ='binary' or @typeout ='char' or @typeout ='nchar'
) -- binary, char, nchar
begin
select @type = @typeout + '(' + rtrim(convert(nchar, @len)) + ')'
return
end
if (@typeout = 'numeric' or @typeout = 'decimal'
or @typeout ='decimaln' or @typeout ='numericn'
) -- decimaln, numericn
begin
select @type = @typeout + '(' + rtrim(convert(nchar, @prec)) + ',' +
rtrim(convert(nchar, @scale)) + ')'
return
end
select @type = @typeout