Pages

Ads 468x60px

Social Icons

Featured Posts

Search

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.

SQL Server data typeCLR data type (SQL Server)CLR data type (.NET Framework)
varbinarySqlBytes, SqlBinaryByte[]
binarySqlBytes, SqlBinaryByte[]
varbinary(1), binary(1)SqlBytes, SqlBinarybyte, Byte[]
imageNoneNone
varcharNoneNone
charNoneNone
nvarchar(1), nchar(1)SqlChars, SqlStringChar, String, Char[]
nvarcharSqlChars, SqlStringString, Char[]
ncharSqlChars, SqlStringString, Char[]
textNoneNone
ntextNoneNone
uniqueidentifierSqlGuidGuid
rowversionNoneByte[]
bitSqlBooleanBoolean
tinyintSqlByteByte
smallintSqlInt16Int16
intSqlInt32Int32
bigintSqlInt64Int64
smallmoneySqlMoneyDecimal
moneySqlMoneyDecimal
numericSqlDecimalDecimal
decimalSqlDecimalDecimal
realSqlSingleSingle
floatSqlDoubleDouble
smalldatetimeSqlDateTimeDateTime
datetimeSqlDateTimeDateTime
sql_variantNoneObject
User-defined type(UDT)user-defined typeNone
tableNoneNone
cursorNoneNone
timestampNoneNone
xmlSqlXmlNone


6 comments

  1. Emmanuel Ruiz : MCP, .NET, SQL, CSS...6 July 2011 at 15:14

    This is good
    But you should update this information to also specify the min and max size supported by each data type.

    ReplyDelete
  2. 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

    ReplyDelete
  3. That's a really useful table :)
    But 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).

    ReplyDelete
  4. .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

    ReplyDelete
  5. Muchas gracias espero este correcta las equivalencias.. si thanks so much .. I hope you're right

    ReplyDelete
  6. I read a lot of interesting content here. Probably you spend a lot of time writing, i know
    how 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

    ReplyDelete

 

Most Popular