Data Types in SQL Server 2000

Source: Internet
Author: User

A data type is a type of data attribute, indicating the type of information represented by the data. Any computer language defines its own data type. Of course, different programming languages have different characteristics. The types and names of the defined data types are more or less different. Sqlserver provides 25 data types:

· Binary [(n)]
· Varbinary [(n)]
· Char [(n)]
· Varchar [(n)]
· Nchar [(n)]
· Nvarchar [(n)]
· Datetime
· Smalldatetime
· Decimal [(P [, S])]
· Numeric [(P [, S])]
· Float [(n)]
· Real
· Int
· Smallint
· Tinyint
· Money
· Smallmoney
· Bit
· Cursor
· Sysname
· Timestamp
· Uniqueidentifier
· Text
· Image
· Ntext
(1) binary data type

Binary data includes binary, varbinary, and image
The binary data type can be either fixed-length (Binary) or variable-length.
Binary [(n)] is a fixed N-bit binary data. The value range of N is from 1 to 8000. The memory size is n + 4 bytes.
Varbinary [(n)] is a binary data with N-bit varying length. The value range of N is from 1 to 8000. The memory size is n + 4 bytes, not n Bytes.
The data stored in the image data type is stored as a bit string, which is not explained by SQL Server and must be explained by the application. For example, an application can store data in the image data type in BMP, tief, GIF, and JPEG formats.
(2) character data type

Character data types include char, varchar, and text
Character data is composed of any combination of letters, symbols, and numbers.
Varchar is a variable-length data with a length of no more than 8 KB. Char is a fixed-length character data with a maximum length of 8 KB. ASCII data larger than 8 KB can be stored as text data. For example, because all HTML documents are ASCII characters and generally exceed 8 kb in length, these documents can be stored in SQL Server as text data.
(3) Unicode Data Type

Unicode data types include nchar, nvarchar, and ntext
In Microsoft SQL Server, traditional non-Unicode data types allow the use of characters defined by specific character sets. You can select a character set during SQL Server installation. The Unicode data type allows columns to store any characters defined by the Unicode standard. The Unicode Standard contains all characters defined in various character sets. When Unicode data types are used, the odds are two times the bytes used by non-Unicode data types.
In SQL Server, Unicode data is stored as nchar, nvarchar, and ntext data. Columns stored with this character type can store characters in multiple character sets. When the length of a column changes, the nvarchar character type should be used. At this time, a maximum of 4000 characters can be stored. When the column length remains unchanged, the nchar character type should be used. Similarly, a maximum of 4000 characters can be stored. When the ntext data type is used, this column can store more than 4000 characters.
(4) Date and Time Data Types

Date and Time data types include datetime and smalldatetime.
The date and time data types are composed of valid date and time. For example, valid date and time data includes "4/01/98 12: 15: 00: 00: 00 PM" and "1: 28: 29: 15: 01 am 8/17/98 ". The previous data type is before the date, the time is before the last data type is before the time, and the date is after. In Microsoft SQL Server, when the date and time data types include datetime and smalldatetime, the stored date range is from 1753

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.