This function is a helper that is used in our DDL scripts
-- =============================================
-- Create scalar function (FN)
-- =============================================
IF EXISTS (SELECT *
FROM sysobjects
WHERE name = N'f_4P_columnType')
DROP FUNCTION f_4P_columnType
GO
CREATE FUNCTION f_4P_columnType
(@intColumnType as int,@intLength int, @intPrecision int , @intscale int)
-- select dbo.f_4P_columnType(56,0,0,0)
RETURNS varchar(20)
AS
BEGIN
declare @out varchar(20)
select @out =
case when @intColumnType = 56 then 'int'
when @intColumnType = 48 then 'tinyint'
when @intColumnType = 36 then 'uniqueidentifier'
when @intColumnType = 52 then 'smallint'
when @intColumnType = 60 then 'money'
when @intColumnType = 45 then 'bit'
when @intColumnType = 62 then 'float'
when @intColumnType = 35 then 'text'
when @intColumnType = 61 then 'datetime'
when @intColumnType = 189 then 'timestamp'
when @intColumnType = 239 then 'nvar(' + convert(varchar(4),@intLength) + ')'
when @intColumnType = 231 then 'nvarchar(' + convert(varchar(4),@intLength) + ')'
when @intColumnType = 173 then 'binary(' + convert(varchar(4),@intLength) + ')'
when @intColumnType in (175,47) then 'char(' + convert(varchar(4),@intLength) + ')'
when @intColumnType = 167 then 'varchar(' + convert(varchar(4),@intLength) + ')'
when @intColumnType in (108,63) then 'numeric(' + convert(varchar(4),@intPrecision) + ',' + convert(varchar(4),@intscale) + ')'
when @intColumnType in (106) then 'numeric(' + convert(varchar(4),@intPrecision) + ',' + convert(varchar(4),@intscale) + ')'
else 'dunno - ' + convert(varchar(4),@intColumnType)
end
return @out
END
GO