Search
Monday, November 19, 2018 ..:: Home ::.. Register  Login
   Calendar  
     
  
   Search  
     
  
   Blogroll  
     
  
   Disclosure  
All blog entries are the opinions of the author and do not necessarily reflect the opinions of their employer. All the code presented is for explanation and demonstration purposes only. Any damages incurred to your site and/or data are not the responsibility of the author. Every effort is taken to ensure the code properly compiles, however sometimes there are some hiccups and you might be required to do your own debugging.
     
  
   TechTidBits (Blog)  

Mapping between .NET CLR types and SQL Server types

Oct 17

Written by:
Friday, October 17, 2008 9:56 AM  RssIcon

Every once in a while I want to know how the CLR datatypes map up to the SQL Server data types and I can never remember the link.  Well, here it is.

http://msdn.microsoft.com/en-us/library/ms131092.aspx

Here's a quick chart.

SQL Server data type

CLR data type (SQL Server)

CLR data type (.NET Framework)

binary

SqlBytes, SqlBinary

Byte[]

bit

SqlBoolean

Boolean, Nullable

char

None

None

date

SqlDateTime

DateTime, Nullable

datetime

SqlDateTime

DateTime, Nullable

decimal

SqlDecimal

Decimal, Nullable

float

SqlDouble

Double, Nullable

int

SqlInt32

Int32, Nullable

money

SqlMoney

Decimal, Nullable

nchar

SqlChars, SqlString

String, Char[]

ntext

None

None

numeric

SqlDecimal

Decimal, Nullable

nvarchar

SqlChars, SqlString

SQLChars is a better match for data transfer and access, and SQLString is a better match for performing String operations.

String, Char[]

text

None

None

time

TimeSpan

TimeSpan, Nullable

timestamp

None

None

tinyint

SqlByte

Byte, Nullable

uniqueidentifier

SqlGuid

Guid, Nullable

User-defined type(UDT)

None

The same class that is bound to the user-defined type in the same assembly or a dependent assembly.

varchar

None

None

xml

SqlXml

None

Tags:
Categories:
Location: Blogs Parent Separator TechTidBits

Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Add Comment   Cancel 
     
  
Copyright 1999-2012 by PCHenry.com   Terms Of Use  Privacy Statement