You are on page 1of 3

MS SQL DataTypes QuickRef

http://webcoder.info/reference/MSSQLDataTypes.html

1.4, 2004-06-23
Brian Lalonde

SQL Server Datatypes Family name bigint2000 int smallint tinyint Integer money Monetary smallmoney datetime Date/Time smalldatetime bit timestamp uniqueidentifier7 Special Approximate float[(n)] real Numeric
Exact Numeric

Binary

Character Text and Image

ADO Constant (reported) adBigInt=20 adInteger=3 adSmallInt=2 adUnsignedTinyInt=17 adCurrency=6 adCurrency=6 adDBTimeStamp=135 adDBTimeStamp=135 adBoolean=11 adBinary=128 adGUID=72 adDouble=5 adSingle=4 adDecimal=14 decimal[(p[,s])] (adNumeric=131) numeric[(p[,s])] adNumeric=131 binary[(n)] adBinary=128 adVarBinary=204 varbinary[(n)] (adBinary=128) adChar=129 char[(n)] nchar[(n)]7 adWChar=130 adVarWChar=202 nvarchar[(n)]7 (adWChar=130) adVarChar=200 varchar[(n)] (adChar=129) adLongVarChar=201 text (adChar=129)

bytes 8 4 2 1 8 4 8 4 1 8 16 8 4 p < 9/19/28/38 =5/9/13/17 n m <= n n n*2 m <= n*2 m <= n <= 2,147,483,647

lower bound -9,223,372,036,854,775,808 -2,147,483,648 -32,768 0 -922,337,203,685,477.5808 -214,748.3648 Jan 1, 1753 Jan 1, 1900 0

upper bound 9,223,372,036,854,775,807 2,147,483,647 32,767 255 922,337,203,685,477.5807 214,748.3647 Dec 31, 9999 Dec 31, 2079 1

synonym binary varying [national] character[(n)] [national] character varying(n) [national] text dec integer double precision float(1-7) float(8-15)

datatype varbinary [n]char[(n)] [n]varchar(n) ntext decimal int float real float

sql_variant2000 sql_variant stores any datatype except text, ntext, image, timestamp, and sql_variant (max 8016 bytes, adVarBinary=204).

1 de 3

01/12/2010 11:11 p.m.

MS SQL DataTypes QuickRef

http://webcoder.info/reference/MSSQLDataTypes.html

ntext7 image

adLongVarWChar=203

(adWChar=130)
adLongVarBinary=205 (adBinary=128)

Columns Date Conversion Date Parts ADO OpenSchema # Format date part TSQL abbrev VBScript abbrev lower bound upper bound adSchemaColumns=4 100* mon dd yyyy hh:miAM year yy yyyy 1753 9999 The ADO OpenSchema 101 mm/dd/yyyy quarter qq q 1 4 method returns incomplete info in the DATA_TYPE 102 yyyy.mm.dd month mm m 1 12 column for many data types. 103 dd/mm/yyyy day of year dy y 1 366 104 dd.mm.yyyy day dd d 1 31 Variable length columns are 105 dd-mm-yyyy week wk ww 1 53 represented by fixed-length 106 dd mon yyyy weekday dw w 1 (Sun) 7 (Sat) types, with the 107 mon dd, yyyy hour hh h 0 23 adFldFixed=16 flag in COLUMN_FLAGS clear. 108 hh:mm:ss minute mi n 0 59 109* mon dd yyyy hh:mi:ss:mmmAM second ss s 0 59 Long fields have the adFldLong=128 flag set in 110 mm-dd-yyyy millisecond ms 0 999 COLUMN_FLAGS. 111 yyyy/mm/dd datetime_new= dateadd(datepart,number,datetime) The smallmoney 112 yyyymmdd NUMERIC_PRECISION is less 113* dd mon yyyy hh:mm:ss:mmm(24h) number_diff= datediff(datepart,from_datetime,to_datetime) than 19, distinguishing it 114 hh:mi:ss:mmm(24h) from money. string_name= datename(datepart,datetime) *2-digit year unavailable The smalldatetime number_value= datepart(datepart,datetime) datatype cannot be distinguished from datetime (but the former is of limited usefulness given the range, so is perhaps best avoided).
Defaults are indicated by COLUMN_HASDEFAULT and available in COLUMN_DEFAULT. Character (and binary) field lengths are given in CHARACTER_MAXIMUM_LENGTH.
CHARACTER_OCTET_LENGTH contains the field's length in bytes.

Numeric column precision and scale are given by NUMERIC_PRECISION and NUMERIC_SCALE, respectively. Finally, IS_NULLABLE denotes whether the field may contain null values.

ADO OpenSchema adSchemaProcedureParameters=26


2 de 3

01/12/2010 11:11 p.m.

MS SQL DataTypes QuickRef

http://webcoder.info/reference/MSSQLDataTypes.html

The ADO OpenSchema method returns incomplete info in the DATA_TYPE column for many data types. The COLUMN_FLAGS field is not available. The TYPE_NAME column returned for stored procedure parameters can be used for accurate type information. The smallmoney NUMERIC_PRECISION is less than 19, distinguishing it from money.

The smalldatetime datatype cannot be distinguished from datetime (but the former is of limited usefulness given the range, so is perhaps best avoided). Defaults are indicated by PARAMETER_HASDEFAULT and available in PARAMETER_DEFAULT.
PARAMETER_TYPE is the direction of the parameter: adParamInput=1, adParamInputOutput=3, adParamOutput=2, adParamReturnValue=4, or adParamUnknown=0.

Character (and binary) field lengths are given in CHARACTER_MAXIMUM_LENGTH.


CHARACTER_OCTET_LENGTH contains the field's length in bytes.

Numeric column precision and scale are given by NUMERIC_PRECISION and NUMERIC_SCALE, respectively. Finally, IS_NULLABLE denotes whether the field may contain null values.

This work is licensed under a Creative Commons Attribution-Share Alike 3.0 License.

3 de 3

01/12/2010 11:11 p.m.

You might also like