Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

casting a tiny int from SQL server

I'm using linq to sql to populate a list of objects. One of the fields I'm interested in is stored as a tinyint. How should I declare this property type in my object definition? As a Short? Byte? Int16?

Thanks.

like image 419
frenchie Avatar asked Feb 17 '11 20:02

frenchie


People also ask

How do you CAST decimals in SQL?

Use the CAST() function to convert an integer to a DECIMAL data type. This function takes an expression or a column name as the argument, followed by the keyword AS and the new data type. In our example, we converted an integer (12) to a decimal value (12.00).

What is Tinyint in SQL Server?

The TINYINT data type is an integer value from 0 to 255. TINYINT is the smallest integer data type and only uses 1 byte of storage. An example usage of TINYINT is a person's age since no person reaches the age of 255.

What does Tinyint 1 mean?

The number 1 used in parenthesis is only for width display. The INT(1) and TINYINT(1) does not influence the storage. The TINYINT takes 1 byte that means it has range -128 to +127 while int takes 4 bytes; it has range -2147483648 to +2147483647.

How do you specify an INT in SQL?

In MySQL, INTEGER (INT) is a numeric value without a decimal. It defines whole numbers that can be stored in a field or column. In addition, MySQL supports the display_width attribute (for example, INT(1)) and the ZEROFILL attribute, which automatically adds zeros to the value depending on the display width.


4 Answers

It will be a byte. Here is a complete list.

like image 193
Mark Avenius Avatar answered Oct 05 '22 10:10

Mark Avenius


It's a byte.

MSDN SqlDbType

like image 35
Austin Salonen Avatar answered Oct 05 '22 10:10

Austin Salonen


Byte

[some extra characters..]

like image 40
dotjoe Avatar answered Oct 05 '22 10:10

dotjoe


It's an unsigned byte, so Byte.

like image 24
egrunin Avatar answered Oct 05 '22 10:10

egrunin