| SQL Server data type | CLR data type (SQL Server) | CLR data type (.NET Framework) |
| varbinary | SqlBytes, SqlBinary | Byte[] |
| binary | SqlBytes, SqlBinary | Byte[] |
| varbinary(1), binary(1) | SqlBytes, SqlBinary | byte, Byte[] |
| image | None | None |
| varchar | None | None |
| char | None | None |
| nvarchar(1), nchar(1) | SqlChars, SqlString | Char, String, Char[] |
| nvarchar | SqlChars, SqlString | String, Char[] |
| nchar | SqlChars, SqlString | String, Char[] |
| text | None | None |
| ntext | None | None |
| uniqueidentifier | SqlGuid | Guid |
| rowversion | None | Byte[] |
| bit | SqlBoolean | Boolean |
| tinyint | SqlByte | Byte |
| smallint | SqlInt16 | Int16 |
| int | SqlInt32 | Int32 |
| bigint | SqlInt64 | Int64 |
| smallmoney | SqlMoney | Decimal |
| money | SqlMoney | Decimal |
| numeric | SqlDecimal | Decimal |
| decimal | SqlDecimal | Decimal |
| real | SqlSingle | Single |
| float | SqlDouble | Double |
| smalldatetime | SqlDateTime | DateTime |
| datetime | SqlDateTime | DateTime |
| sql_variant | None | Object |
| User-defined type(UDT) | user-defined type | None |
| table | None | None |
| cursor | None | None |
| timestamp | None | None |
| xml | SqlXml | None |
SQL Data Types vs. C# Data Types
Friday, 15 April 2011
This article is just a reference of SQL Data Types to C# Data Types.
Subscribe to:
Post Comments (Atom)
This is good
ReplyDeleteBut you should update this information to also specify the min and max size supported by each data type.
This is nice. However, it could be better. For example, when actually writing C# code, instead of "Int64" one should use "long", by convention and best-practice. That is what Microsoft has recommended. The matrix ought to reflect such conventions. Regardless, it is a decent matrix. Thanks. -- Mark Kamoski
ReplyDeleteThat's a really useful table :)
ReplyDeleteBut I think the varbinary(1), binary(1) for storing one byte is wrong. I tested it and was not able to store, for example, 0xAA into a varbinary(1), binary(1).
.net grid provides broad capabilities of working with data such as arbitrary class objects, row arrays, objects implementing IList or IDictionary interfaces and objects with variable number of fields dapfor. com
ReplyDeleteMuchas gracias espero este correcta las equivalencias.. si thanks so much .. I hope you're right
ReplyDeleteI read a lot of interesting content here. Probably you spend a lot of time writing, i know
ReplyDeletehow to save you a lot of work, there is an online tool that creates high quality, google friendly posts in minutes, just search
in google - laranitas free content source