Creating Table’s Property Values in SQL Server

Hello everyone,

In this article, I will try to give information about creating the Property values of the table in SQL Server.

You may want to see the Csharp or Java Property equivalents of the tables we have created in SQL Server.

You can easily do this using the code below.

SELECT 'public ' + CASE DATA_TYPE
                       WHEN 'bigint' THEN
                           'int'
                       WHEN 'binary' THEN
                           'Byte[]'
                       WHEN 'bit' THEN
                           'int'
                       WHEN 'char' THEN
                           'char'
                       WHEN 'datetime' THEN
                           'DateTime'
                       WHEN 'decimal' THEN
                           'decimal'
                       WHEN 'float' THEN
                           'float'
                       WHEN 'image' THEN
                           'Byte[]'
                       WHEN 'int' THEN
                           'int'
                       WHEN 'money' THEN
                           'double'
                       WHEN 'nchar' THEN
                           'string'
                       WHEN 'ntext' THEN
                           'string'
                       WHEN 'nvarchar' THEN
                           'string'
                       WHEN 'numeric' THEN
                           'int'
                       WHEN 'real' THEN
                           'decimal'
                       WHEN 'smalldatetime' THEN
                           'DateTime'
                       WHEN 'smallmoney' THEN
                           'double'
                       WHEN 'smallint' THEN
                           'int'
                       WHEN 'text' THEN
                           'string'
                       WHEN 'timestamp' THEN
                           'Date'
                       WHEN 'uniqueidentifier' THEN
                           'string'
                       WHEN 'varbinary' THEN
                           'Byte[]'
                       WHEN 'varchar' THEN
                           'string'
                       ELSE
                           'Unknwon Type ' + DATA_TYPE + ' DataType'
                   END + ' ' + COLUMN_NAME + ' { get; set; }'
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'Categories'; --You will change the database table name from this section.

When you run the above code, you will see a result similar to the one below.

Creating Table's Property Values in SQL Server

As you can see, the Property values of the relevant table have been created.

Good luck to everyone in business and life.

86 Views

Yavuz Selim Kart

I try to explain what I know in software and database. I am still improving myself by doing research on many programming languages. Apart from these, I am also interested in Graphic Design and Wordpress. I also have knowledge about SEO and Social media management. In short, I am a determined person who likes to work hard.

You may also like...

Don`t copy text!