Select distinct 'public ' || case Lower(DATA_TYPE) when 'raw' then 'Guid?' when 'number' then 'Decimal?' when 'char' then 'string' when 'date' then 'DateTime?' when 'decimal' then 'decimal?' when 'nvarchar' then 'string?' when 'uniqueidentifier' then 'Guid?' when 'varchar2' then 'string' else 'UNKNOWN_' || DATA_TYPE end|| ' ' || replace(initcap(replace(Column_name,'_',' ')),' ','') || ' { get; set; }' , all_tab_columns.column_id from all_tab_columns where table_name= upper('SPA_DISCOUNT_GROUP') order by all_tab_columns.column_id select * from all_tab_columns where table_name= upper('SPA_DISCOUNT_GROUP') --------------- Result --------------
Get C# class Declaration from SQL Table structure ------------ CODE ---------- to be executed in SQL --------- declare @TableName sysname = 'Transaction_document' declare @Result varchar ( max ) = 'public class ' + @TableName + ' {' select @Result = @Result + ' public ' + ColumnType + NullableSign + ' ' + ColumnName + ' { get; set; } ' from ( select replace ( col . name , ' ' , '_' ) ColumnName , column_id ColumnId , case typ . name when 'bigint' then 'long' when 'binary' then 'byte[]' when 'bit' then 'bool' when 'char' then 'string' when 'date' then 'DateTime' when 'datetime' then 'DateTime' when 'datetime2' then &