ddf_ColumnNameVB

Returns the variable name that we want to use in VB for a SQL table column

 

IF EXISTS (SELECT *
    FROM   sysobjects
    WHERE  name = N'ddf_ColumnNameVB')
 DROP FUNCTION ddf_ColumnNameVB
GO
 
CREATE FUNCTION ddf_ColumnNameVB
 (@data_type as varchar(255), @Column_name varchar(128))
--select dbo.ddf_ColumnNameVB('decimal')
--sp_sps
 
RETURNS varchar(30)
 
AS
BEGIN
    declare @out varchar(30)
 
    select @out =
        case
            --when @date_type in('tinyint') then 'Int16' /* tinyint  */
            --when @date_type in('smallint') then 'Int16' /* smallint  */
            when @data_type in('int') then 'int' + @Column_name /* int  */
            --when @date_type in('bigint') then 'Int64' /* bigint  */
            --when @date_type = 'bit' then 'Boolean' /* bit */
            --when @date_type = 'uniqueidentifier' then 'GUID'
            when @data_type in ('numeric','float','money','decimal','x') then 'dec' + @Column_name
            --when @date_type in ('bit', '') then 'Boolean'
            when @data_type in ('varchar','nvarchar','char', 'nchar', 'text','') then 'str' + @Column_name
            --when @date_type in ('datetime') then 'DateTime'
            --when @date_type in ('date') then 'Date'
            --when @date_type in ('time') then 'DateTime' /* time */
            --WHEN @date_type = 'binary' THEN 'Byte()' /* binary */
            --WHEN @date_type = 'timestamp' THEN 'Byte()' /* timestamp */
            else 'DUnno - ' + convert(varchar(20),@data_type)
            end
     
    return @out
 
END
GO
--sp_help sop10200

 


RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences