Site Search:
Sign in | Join | Help
4Penny.net

SQL Server (T-SQL)

Comments and notes on SQL Server 2000, 2005, and T-SQL

f_4P_columnTypeVB

This is a helper function used in DDL scripts 

-- =============================================
-- v 1.5 
-- =============================================
IF EXISTS (SELECT * 
    FROM   sysobjects 
    WHERE  name = N'f_4P_columnTypeVB')
 DROP FUNCTION f_4P_columnTypeVB
GO


CREATE FUNCTION f_4P_columnTypeVB 
 (@intColumnType as int)


-- select dbo.f_4P_columnTypeVB(56)


RETURNS varchar(20)


AS
BEGIN
declare @out varchar(20)


select @out = 
 case when @intColumnType in(48,52, 56) then 'system.int64'
  when @intColumnType = 36 then 'GUID'
  when @intColumnType in(108,60,63,106) then 'double'
  when @intColumnType = 45 then 'boolean'
  when @intColumnType in (35,47,167, 175,231) then 'string'
  when @intColumnType = 61 then 'date'
  when @intColumnType = 104 then 'int16' --bit
  --when @intColumnType = 173 then 'binary(' + convert(varchar(4),@intLength) + ')'
  else 'dunno - ' + convert(varchar(4),@intColumnType)
  end 


 return @out



END
GO


 


 

Comments

No Comments

About Steve Gray

Steve is a seasoned (translate: old) developer in VB and ASP.NET. He spends most of his time in Dynamics GP, writing custom mods for consulting firms. Crystal reports, eConnect, VS Tools for Dynamics... anything that comes along.