SQL Server 2008 R2——Data Types

In SQL Server, each column, local variable, expression, and parameter has a related data type. A data type is an attribute that specifies the type of data that the object can hold: integer data, character data, monetary data, date and time data, binary strings, and so on.

SQL Server supplies a set of system data types that define all the types of data that can be used with SQL Server. You can also define your own data types in Transact-SQL or the Microsoft .NET Framework. Alias data types are based on the system-supplied data types. For more information about alias data types, seeWorking with Alias Data Types. User-defined types obtain their characteristics from the methods and operators of a class that you create by using one of the programming languages support by the .NET Framework. For more information, see Working with CLR User-defined Types.

When two expressions that have different data types, collations, precision, scale, or length are combined by an operator, the characteristics of result are determined by the following:

  • The data type of the result is determined by applying the rules of data type precedence to the data types of the input expressions. For more information, seeData Type Precedence (Transact-SQL).
  • The collation of the result is determined by the rules of collation precedence when the result data type is char, varchar, text, nchar, nvarchar, or ntext. For more information, see Collation Precedence (Transact-SQL).
  • The precision, scale, and length of the result depend on the precision, scale, and length of the input expressions. For more information, see Precision, Scale, and Length (Transact-SQL).

SQL Server provides data type synonyms for ISO compatibility. For more information, see Data Type Synonyms (Transact-SQL).

Data Type Categories

Data types in SQL Server are organized into the following categories:


Exact numerics


Unicode character strings


Approximate numerics


Binary strings


Date and time


Other data types


Character strings

In SQL Server, based on their storage characteristics, some data types are designated as belonging to the following groups:

  • Large value data types: varchar(max), nvarchar(max), and varbinary(max)
  • Large object data types: text, ntext, image, varchar(max), nvarchar(max), varbinary(max), and xml
    Note

    sp_help returns -1 as the length for the large-value and xml data types.

Exact Numerics


bigint


numeric


bit


smallint


decimal


smallmoney


int


tinyint


money

Approximate Numerics


float


real

Date and Time


date


datetimeoffset


datetime2


smalldatetime


datetime


time

Character Strings


char


varchar


text

Unicode Character Strings


nchar


nvarchar


ntext

Binary Strings


binary


varbinary


image

Other Data Types


cursor


timestamp


hierarchyid


uniqueidentifier


sql_variant


xml


table

 
时间: 2024-08-28 01:44:11

SQL Server 2008 R2——Data Types的相关文章

SQL Server 2008 R2 升级到 Service Pack 3后Report Builder启动不了

一同事将测试服务器从SQL Server 2008 R2 SP2升级到了SQL Server 2008 R2 SP3后发现Report Service的报表编辑时启动不了Report Builder,错误信息如下所示: PLATFORM VERSION INFO     Windows             : 6.1.7601.65536 (Win32NT)     Common Language Runtime     : 4.0.30319.18408     System.Deploy

SQL Server 2008 R2 下移动数据库的存储位置

使用场景:1. 该数据库增长的较大,存储磁盘空间不足:   2. 在特定情况下该数据库需要移动到另外一块磁盘上(呵呵...我的情况就是之前的磁盘要还给别人) 步骤: 1. 新建查询 SELECT name, physical_name FROM sys.master_files WHERE database_id = DB_ID('yourDataBaseName'); GO 查看到结果会看到数据库主文件以及日志的名称和物理存储的地址名称   2.新建查询 use master alter da

SQL Server 2008 R2 里迁移系统数据库的方法

针对不同的场景,采用不同的步骤. 对非master以及resource系统数据库而言,分两种情况. 1.非master以及resource系统数据库正常. 这里以迁移msdb为例,将msdb从D:\SQL2K8_DATA\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\迁移到D:\SQL2K8_DATA\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\system\目录下. 首先我们检查当前msdb的路径 ? 1 2 3 SELECT name, phys

SQL Server 2008 R2 性能计数器详细列表(二)

原文:SQL Server 2008 R2 性能计数器详细列表(二) SQL Server Buffer Partition 对象: 提供计数器来监视 SQL Server 如何使用可用页 SQL Server Buffer Partition 计数器 说明 Free list empty/sec 每秒钟请求但无法提供可用页的次数. Free list requests/sec 每秒请求可用页的次数. Free pages 所有可用列表的总页数. SQL Server CLR 对象: 监视 Mi

Sql Server数据库 002—sql server 2008 r2 连接字符串

安装完了数据库,在程序中使用就需要连接字符串.如何写呢?以sql server 2008 r2后为例.1.安装好sql server 2008 r2后,类似oracle的plsql工具.sql server 2008 r2也有工具,那就是sql server management studio,如图 2.打开sql server management studio后,如图 服务器,用户名,密码都是在安装的时候自己输入的. 3.进入界面,可以创建自己的数据库名.也可以点击附件导入已有的数据库(md

SQL Server 2008 R2没有卸载干净

在卸载Microsoft SQL Server 2008 R2 安装程序(简体中文) 出现 :“警告 26003.无法卸载 Microsoft SQL Server 2008 R2 安装程序支持文件,因为安装了以下产品:SQL Server 2008 R2 SP1 Database Engine Shared SQL Server 2008 R2 SP1 Common Files”.但是在程序列表中并未找到该程序,在网上找了找资料,可以使用 WMIC(Windows Management Ins

SQL Server 2008 R2 附加数据库 “尝试打开或创建物理文件 拒绝访问”的解决办法

其实是来自一篇SQL Server 2005同样错误的帖子,不过试了在SQL Server 2008 R2下面也有效,记录一下. 解决方法: 在所有程序—Microsoft SQL Server 2008 R2—配置工具—SQL Server 配置管理器,点击"SQL Server 服务",右边会显示正在运行的服务,以及对应的用户,右击SQL Server (MSSQLSERVER),选择“属性”,把内置帐户选择为"Local System",点击重新启动就OK了.

sql server 2008 r2 修改sa密码 通过sql server 身份验证登陆

sql server 2008 r2 修改sa密码 通过sql server 身份验证登陆 解决方法如下 通过windows 身份验证登陆后, 首先选中服务器(右键)->属性 ->安全性->服务器身份验证修改为"SQL SERVER和WINDOWS身份验证模式"其次展开服务器上的"安全性"->登陆名->选中SA登陆帐号(右键)->状态->登陆修改为启用, 并在常规选项中修改密码 确认后重启 sel server sql se

Sql Server 2008 R2 数据库脚本导出方法

经常忘记怎么搞,截几张图记录一下. 1 选中要导出的数据库,右键->任务->生成脚本 2 3 4 查看保存的脚本 Sql Server 2008 R2 数据库脚本导出方法,布布扣,bubuko.com