SQL Server: Data Types - Part 2

SQL Server: Data Types - Part 2

Date and Time Types

SQL server supports following date and time types

Date: Defines a date

Time [(fractional seconds precision)]: Define the time of day the time is without time zone awareness and is based on a 24-hour clock.

DateTime: Defines a date that is combined with the time of day with fractional seconds that is based on 24-hour clock.

SmallDateTime: Defines a date that is combined with the time of day the time is based on a 24-hour clock with seconds always (:00) and without fractional seconds.

DateTime2 [(Fractional seconds precision)]: Define a date that is combined with the time of day that is based on 24-hour clock datetime2 can be considered as an extension of the above DateTime type that has a larger date range.

Datetimeoffset [(Fractional seconds precision)]: Defines a date that is combined with the time of a day that has time zone awareness and is based on a 24-hour clock.

No alt text provided for this image

Character Types

These are string data types of either fixed length or variable length

char[(n)]: Fixed length non-Unicode string data and defines the string length and must be a value from 1 to 8000 the storage size is n bytes.

varchar[(n/max)]: Variable length non-Unicode string data and defines the string length and can be a value from 1 to 8000 Max indicates that the maximum storage size is 2 ^ 31 - 1 byte (2 GB ).The storage size is the actual length of the data entered + 2 bytes.

text: same as varchar(Max).

nchar[(n)]: Fixed length Unicode string data. n defines the string length and must be a value from 1 to 4000 the storage size is 2 times of n bytes.

nvarchar[(n/max)]: Variable length Unicode string data. n defines the string length and can be a value from 1 to 4000 max indicates that the maximum storage size is 2^31 - 1 byte (2GB). the storage size in bytes is two times the actual length of data entered + 2 bytes.

ntext: Same as nvarchar(max).

In my next article, I will explain about remaining data types.

要查看或添加评论,请登录

Yadagiri Reddy Hanumandla的更多文章

  • Mastering XPath just in 45 minutes

    Mastering XPath just in 45 minutes

    XPath is one of the most popular and very useful locators available in Selenium WebDriver. Using XPath we can find…

    1 条评论
  • SQL Server: Data Types - Part 1

    SQL Server: Data Types - Part 1

    Question: Do we have data types in SQL server? Answer: Yes, we have data types in SQL server. Now will see what the…

  • SQL Server: Creation of user-defined database

    SQL Server: Creation of user-defined database

    User-defined Database: A Database which is created and managed by the users for storing their objects like Tables…

  • SQL Server: What is Database and types of a database?

    SQL Server: What is Database and types of a database?

    Database: A database is a special software that is designed to manage the data. In between, the 60's and 70's, the…

社区洞察

其他会员也浏览了