byte |
tinyint |
Range: 0 to 255 (unsigned in both C# and SQL Server) |
short |
smallint |
Range: –32,768 to 32,767 |
int |
int |
Standard 32-bit signed integer |
long |
bigint |
For very large signed integers |
bool |
bit |
Represents 0 (false) or 1 (true) |
decimal |
decimal(p,s) |
Specify precision & scale |
float |
real |
Approx. numeric, 4-byte |
double |
float |
Approx. numeric, 8-byte |
char |
nchar(1) |
Fixed-length Unicode character |
string |
nvarchar(n) or varchar(n) |
Unicode vs non-Unicode text |
DateTime |
datetime or datetime2 |
Use datetime2 for higher precision |
Guid |
uniqueidentifier |
Standard GUID format |
byte[] |
varbinary(n) or image |
For binary data & files |
sbyte |
smallint |
sbyte: –128 to 127; stored in SQL smallint |
ushort |
int |
ushort: 0 to 65,535; SQL has no smalluint |
uint |
bigint |
uint: 0 to 4,294,967,295; no unsigned SQL type |
ulong |
decimal(20,0) |
ulong: very large range; use decimal |