SQL Server
SQL Server
The data type of a programming element refers to what kind of data it can hold and how
that data is stored. Data types apply to all values that can be stored in computer memory
or participate in the evaluation of an expression. Every variable, literal, constant,
property, procedure argument, and procedure return value has a data type.
A data type in a programming language is a set of data with values having predefined
characteristics.
Languages that leave little room for programmers to define their own data types are said
to be strongly-typed languages.
A data type is a value type if it holds the data within its own memory allocation. A
reference type contains a pointer to another memory location that holds the data.
• String
• All arrays, even if their elements are value types
• Class types, such as Form
• Delegates
You can assign either a reference type or a value type to a variable of the Object data
type. An Object variable always holds a pointer to the data, never the data itself.
However, if you assign a value type to an Object variable, it behaves as if it holds its
own data.
You can find out whether an Object variable is acting as a reference type or a value type
by passing it to the IsReference method on the Information class in the
Microsoft.VisualBasic namespace. Microsoft.VisualBasic.Information.IsReference
returns True if the content of the Object variable represents a reference type.
Specifying data types for all your variables is known as strong typing. Using strong
typing has several advantages:
• It enables IntelliSense™ support for your variables. This allows you to see their
properties and other members as you type in the code.
• It allows the compiler to perform type checking. This catches statements that can
fail at run time due to errors such as overflow. It also catches calls to methods on
objects that do not support them.
• It results in faster execution of your code.
The cursor data type is the only system data type that cannot be assigned to a table
column. It can be used only with variables and stored procedure parameters.
• Alias data types are created from base data types. They provide a mechanism for
applying a name to a data type that is more descriptive of the types of values to be
held in the object. This can make it easier for a programmer or database
administrator to understand the intended use of any object defined with the data
type. For example:
Fixed precision and scale numbers. When maximum precision is used, valid
values are from - 10^38 +1 through 10^38 - 1. The SQL-92 synonyms for
decimal are dec and dec(p, s). numeric is functionally equivalent to decimal.
p (precision)
The maximum total number of decimal digits that can be stored, both to the left
and to the right of the decimal point. The precision must be a value from 1
through the maximum precision of 38. The default precision is 18.
s (scale)
The maximum number of decimal digits that can be stored to the right of the
decimal point. Scale must be a value from 0 through p. Scale can be specified
only if precision is specified. The default scale is 0; therefore, 0 <= s <= p.
Maximum storage sizes vary, based on the precision.