Define MSSQL

SQL Data Types

SQL Commands

SQL Create Database

SQL Create Table

SQL Insert Into

SQL Select Query

SQL Orderby

SQL Update Command

Truncate Delete Drop

SQL Select Top

SQL Constraints

SQL Alias

SQL Joins

SQL Union, intersect

SQL Select Into

SQL Insert Into Select

SQL Indexes

SQL Alter Table

SQL AutoIncrement

SQL View

SQL Date Functions

SQL NULL Value

SQL Aggregate Functions

SQL Group By

SQL Scalar functions

Stored Procedure

MS-SQL Data Types

String types:

Data typeDescription
char(n)Fixed width character string. Maximum 8,000 characters
varchar(n) Variable width character string. Maximum 8,000 characters
textVariable width character string. Maximum 2GB of text data
ncharFixed width Unicode string. Maximum 4,000 characters
nvarcharVariable width Unicode string. Maximum 4,000 characters
ntextVariable width Unicode string. Maximum 2GB of text data

Number types:

Data typeDescriptionStorage
tinyintAllows whole numbers from 0 to 2551 byte
smallintAllows whole numbers between -32,768 and 32,7672 bytes
intAllows whole numbers between -2,147,483,648 and 2,147,483,647 4 bytes
bigintAllows whole numbers between -9,223,372,036,854,775,808 and 9,223,372,036,854,775,8078 byte
decimal(p,s)Allows decimal numbers from -10^38 +1 to 10^38 –1 The p parameter indicates the maximum number of digits that can be stored. Value must be between 1 and 38. Default is 18.
The s parameter indicates the maximum number of decimal digits to be stored. Value must be between 0 to p. Default value is 0.
5-17 byte
numeric(p,s)Same as decimal 5-17 byte
floatFloating precision number from -1.79E+ 308 to 1.79E + 308. 8 byte
realFloating precision number from -3.40E + 38 to 3.40E + 38 4 byte

Date types:

Data typeDescription Storage
datetimeFrom January 1, 1753 to December 31, 9999. Format: 'YYYY-MM-DD HH:MM:SS' 8 byte
datetime2From January 1, 0001 to December 31, 9999. Format: 'YYYY-MM-DD HH:MM:SS' 6-8 bytes
smalldatetimeFrom January 1, 1900 to June 6, 2079. Format: 'YYYY-MM-DD HH:MM:SS' 4 bytes
dateStore a date only. From January 1, 0001 to December 31, 9999. In a Format 'YYYY-MM-DD' 3 byte
timeStore a time only to an accuracy of 100 nanoseconds 3-5 byte