Sie sind auf Seite 1von 2

MS SQL DataTypes QuickRef

1.4, 2004-06-23
Brian Lalonde

SQL Server Datatypes


Family name bigint2000 ADO Constant (reported) a B g n =20 diIt
aItgr d n e e =3

bytes

lower bound upper bound 8 -9,223,372,036,854,775,808 9,223,372,036,854,775,807 -2,147,483,648 -32,768 0 8 -922,337,203,685,477.5808 -214,748.3648 8 Jan 1, 1753 Jan 1, 1900 1 0 2,147,483,647 32,767 255 922,337,203,685,477.5807 214,748.3647 Dec 31, 9999 Dec 31, 2079 1

int smallint Integer tinyint money Monetary smallmoney datetime Date/Time smalldatetime bit timestamp uniqueidentifier7 Special Approximate float[(n)] Numeric real Exact Numeric decimal[(p[,s])]

4 a S a l n =2 dmlIt 2 aUsgeTnIt d n i n d i y n =17 1 a C r e c =6 durny a C r e c =6 durny 4 aDTmSap d B i e t m =135 aDTmSap d B i e t m =135 4 aBoen d o l a =11 a B n r =128 diay 8 a G I =72 dUD 16
a D u l =5 dobe a S n l =4 dige aDcml d e i a =14

Binary

(a N m r c d u e i =131) numeric[(p[,s])] a N m r c d u e i =131 binary[(n)] a B n r =128 diay aVriay d a B n r =204 varbinary[(n)] (a B n r =128) diay char[(n)] a C a =129 dhr nchar[(n)]7 aWhr d C a =130 nvarchar[(n)]7
a V r C a =202 daWhr

8 4 p< 9/19/28/38 =5/9/13/17 n m <= n n n*2

Character

varchar[(n)] text ntext7

Text and Image

image

m <= n*2 (a W h r d C a =130) aVrhr d a C a =200 m <= n (a C a =129) dhr aLnVrhr d o g a C a =201 (a C a =129) dhr a L n V r C a =203 dogaWhr <= (a W h r d C a =130) 2,147,483,647 aLnVriay d o g a B n r =205 (a B n r =128) diay

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, aVriay d a B n r =204).

Columns Date Conversion


# 100* 101 102 103 104 105 106 107 Format mon dd yyyy hh:miAM mm/dd/yyyy yyyy.mm.dd dd/mm/yyyy dd.mm.yyyy dd-mm-yyyy dd mon yyyy mon dd, yyyy

Date Parts
date part year quarter month day of year day week weekday hour TSQL abbrev yy qq mm dy dd wk dw hh VBScript abbrev yyyy q m y d ww w h lower bound 1753 1 1 1 1 1 1 (Sun) 0

upper bound O e S h m pncea 9999 4 12 366 31 53 7 (Sat) 23

ADO

107 mon dd, yyyy minute mi n 0 59 108 hh:mm:ss 109* mon dd yyyy hh:mi:ss:mmmAM second ss s 0 59 110 mm-dd-yyyy millisecond ms 0 999 111 yyyy/mm/dd datetime_new= d t a d a e d (datepart,number,datetime) 112 yyyymmdd aeif 113* dd mon yyyy hh:mm:ss:mmm(24h) number_diff= d t d f (datepart,from_datetime,to_datetime) 114 hh:mi:ss:mmm(24h) string_name= d t n m (datepart,datetime) aeae *2-digit year unavailable number_value= d t p r (datepart,datetime) aeat
aShmClms d c e a o u n =4

The ADO O e S h m method returns incomplete info in the D T _ Y Ecolumn for many data types. pncea AATP Variable length columns are represented by fixed-length types, with the a F d i e =16 flag in C L M _ L G clear. dlFxd OUNFAS Long fields have the a F d o g d l L n =128 flag set in C L M _ L G . OUNFAS The s a l o e N M R C P E I I Nis less than 19, distinguishing it from m n y mlmny UEI_RCSO oe. The s a l a e i edatatype cannot be distinguished from d t t m (but the former is of limited usefulness given the range, so mldttm aeie is perhaps best avoided). Defaults are indicated by C L M _ A D F U Tand available in C L M _ E A L . OUNHSEAL OUNDFUT Character (and binary) field lengths are given in C A A T R M X M M L N T . HRCE_AIU_EGH
C A A T R O T T L N T contains the field's length in bytes. HRCE_CE_EGH

Numeric column precision and scale are given by N M R C P E I I Nand N M R C S A E respectively. UEI_RCSO UEI_CL, Finally, I _ U L B Edenotes whether the field may contain null values. SNLAL

ADO O e S h m a S h m P o e u e a a e e s p n c e a d c e a r c d r P r m t r =26
The ADO O e S h m method returns incomplete info in the D T _ Y Ecolumn for many data types. pncea AATP The C L M _ L G field is not available. OUNFAS The T P _ A Ecolumn returned for stored procedure parameters can be used for accurate type information. YENM The s a l o e N M R C P E I I Nis less than 19, distinguishing it from m n y mlmny UEI_RCSO oe. The s a l a e i edatatype cannot be distinguished from d t t m (but the former is of limited usefulness given the range, so mldttm aeie is perhaps best avoided). Defaults are indicated by P R M T R H S E A L and available in P R M T R D F U T AAEE_ADFUT AAEE_EAL.
P R M T R T P is the direction of the parameter: a P r m n u =1, a P r m n u O t u =3, a P r m u p t AAEE_YE daaIpt daaIptupt d a a O t u =2, a P r m e u n a u =4, daaRtrVle

or a P r m n n w =0. daaUkon

Character (and binary) field lengths are given in C A A T R M X M M L N T . HRCE_AIU_EGH


C A A T R O T T L N T contains the field's length in bytes. HRCE_CE_EGH

Numeric column precision and scale are given by N M R C P E I I Nand N M R C S A E respectively. UEI_RCSO UEI_CL, Finally, I _ U L B Edenotes whether the field may contain null values. SNLAL

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

Das könnte Ihnen auch gefallen