Data types in SQL Server
---------------------------------------------------------
1. Number Type :
-------------
Data type Size
-------------- ---------
-> tinyint 1 byte
-> smallint 2 byte
-> int 4 byte
-> bigint 8 byte
-> float(n) 4 byte
-> decimal(p,s) 12 byte
-> smallmoney 4 byte
-> money 8 byte
-> numeric(p,s)
2. String type :
----------------
-> char(n) Defined width , Maximum 8,000 characters
-> varchar(n) Variable width character string, Maximum 8,000 characters
-> varchar(max) Maximum 1,073,741,824 characters
-> nchar
-> nvarchar
-> nvarchar(max)
-> text
-> ntext
char data type is called fixed length i.e according to the given size than all the bytes will be used in a memory with this memory will be wastage.
varchar is called variable length based on the given characters only those bytes will be used in memory. It can be called as dynamic memory allocation.
char and varchar will works with an ASCII code. ASCII value will be up to 255. it will used 1 byte for 1 character.
nchar and nvarchar will works with unicode. Unicode values will be upto 65535.
Unicode supports English and other popular languages like Freanch, Lattin, Greak etc. It will uses two bytes for one character.
nchar is called fixed length and nvarchar is called variable length.
3. Binary type :
-------------------
-> bit 1 byte true/false
-> image up to 2 gb
4. Date and time type :
----------------------------
smalldatetime 2 bytes year upto 2079
datetime 4 bytes year upto 9999
date 3 bytes
time 3 bytes
Operators In SQL Server
------------------------------------------------------------
1. Arithmetic Operators
--------------------------------
+ Plus
- Minus
* Multiplication
/ Divide
2. Relational Operators
------------------------------
> greater than
< less than
>= greater than equal to
<= less than equal to
= equal to
!= not equal to
<> not equal to
3. Logical Operators
----------------------------
AND, OR, NOT
4. Special Operators
--------------------------
In
Not In
between
Not between
like
not like
isnull
isnull
not isnull
No comments:
Post a Comment