SlideShare a Scribd company logo
1 of 17
Download to read offline
SQL Server 2016
System DBs, Data Types, DML, JSON, and Built-in Functions
Seyed Ibrahim
System DBs
• master
• All logins, or roles, to which the user IDs belong
• Every system configuration setting (e.g.: data sorting information, security
implementation, default language)
• The names of and information about the databases within the server
• The location of databases
• How SQL Server is initialized
• Several System tables - System error and warning messages, etc.
• tempdb
• lifetime is the duration of a SQL Server session
• Temp tables
System DBs
• model
• the basis for creating the tempdb database & any other database created
• if you want all your databases to have a specific initial size or to have a
specific set of information
• msdb
• provides the necessary information to run jobs to SQL Server Agent
• SQL Server Agent: Windows service that runs any scheduled jobs
Data Definition Language - CREATE
• CREATE DATABASE
• CREATE DEFAULT When bound to a column, specifies a value to be
inserted
• CREATE TABLE
• CREATE VIEW
• CREATE PROCEDURE Creates a T-SQL or common language runtime (CLR) SP
• CREATE FUNCTION Creates a user-defined function in SQL Server
• CREATE TRIGGER Creates a DML, DDL, or logon trigger
• CREATE SEQUENCE Creates a sequence object and specifies its properties
• CREATE LOGIN Creates a Database Engine login for SQL Server
• CREATE ROLE Creates a new database role in the current database
• CREATE USER Adds a user to the current database
Login Vs User
• With a login, you can connect to SQL Server
• It cannot connect to any of the user databases
• user is an account that is database-specific
• a login cannot perform database actions without a valid user account
• The two may have exactly the same name
Data Types
• Exact Numerics
• Bigint (Trillions), int, smallint (-32k to +32k), tinyint
• numeric, decimal – With precision and scale. Almost the same
• bit
• money, smallmoney – Not really used
• Approximate Numerics
• Float (application state depends on the implementation of the floating point
numbers)
• Real (same as Float(24))
Data Types
• Date and Time
• Date 0001-01-01 through 9999-12-31
• Time 00:00:00.0000000 through 23:59:59.9999999
• Datetime January 1, 1753, through December 31, 9999 with Time
• Smalldatetime 1900-01-01 through 2079-06-06 with 00:00:00
• Character Strings
• Char Fixed-length, non-Unicode string data
• Varchar Variable-length, non-Unicode string data
• text Variable-length non-Unicode data (2^31 - 1)
Data Types
• Unicode Character Strings
• Nchar Fixed-length Unicode string data
• Nvarchar Variable-length Unicode string data
• Ntext Variable-length Unicode data
• Binary Strings
• Binary Fixed-length binary data
• Varbinary
• Image Variable-length binary data (2,147,483,647 bytes)
Data Manipulation Language
• INSERT Syntax
INSERT [INTO]
{table_name|view_name}
[{(column_name,column_name,…)}]
{VALUES (expression, expression, …)}
• BULK INSERT Example
BULK INSERT Sales.SalesOrderDetail
FROM 'computer2salesforcedailyordersneworders.txt';
Data Manipulation Language
• DELETE Syntax
DELETE tablename
WHERE where_condition
• TRUNCATE TABLE Example
• will delete data from a table with millions of records in only a few seconds
• cannot issue it against tables that have foreign keys referencing them
TRUNCATE TABLE CustomerDetails.Customers
Data Manipulation Language
• UPDATE
UPDATE dbo.Customers
SET FirstName = ‘Talha'
WHERE CustomerId = 7
• MERGE
• separate insert, update, and delete statements all within the same
statement
• A level above UPSERT: inserts rows that don't exist and updates the
rows that do exist
Types of Built-in Functions
Rowset Functions Return an object that can be used like table references in an SQL statement
OPENXML, OPENROWSET, OPENQUERY ( linked_server ,'query' ) , etc.
Aggregate
Functions
Operate on a collection of values but return a single, summarizing value.
AVG, MIN, MAX, COUNT, SUM, STDDEV, etc.
Ranking Functions Return a ranking value for each row in a partition.
RANK, DENSE_RANK, ROW_NUMBER
Scalar Functions
(Described Next)
Operate on a single value and then return a single value. Scalar functions can
be used wherever an expression is valid.
Scalar Functions
Function category Description & Examples
Conversion Functions CAST and CONVERT - one data type to another
Date and Time Data
Types and Functions
Perform operations on a date and time input values and return string, numeric, or
date and time values.
JSON Functions Validate, query, or change JSON data.
Logical Functions CHOOSE ( index, val_1, val_2,..) , IIF ( boolean_expression, true_value, false_value )
Mathematical Functions Perform calculations based on input values provided as parameters to the functions,
and return numeric values.
Metadata Functions Return information about the database and database objects.
String Functions LEFT, RIGHT, SUBSTRING, UPPER, LOWER, CONCAT, RTRIM, LTRIM, ETC.
System Functions Perform operations and return information about values, objects, and settings.
HOST_NAME, ISNULL, ISNUMERIC, @@ROWCOUNT, ERROR_NUMBER, etc
JSON in SQL 2016
JSON Functions
Function Description
ISJSON Tests whether a string contains valid JSON.
JSON_VALUE Extracts a scalar value from a JSON string.
JSON_QUERY Extracts an object or an array from a JSON string.
JSON_MODIFY Updates the value of a property in a JSON string and returns the updated JSON string
Date and Time Functions
Syntax Return value
SYSDATETIME () & GETDATE ( ) date and time of the computer on which the instance of SQL Server is running
SYSUTCDATETIME ( ) & GETUTCDATE ( ) The date and time is returned as UTC time (Coordinated Universal Time).
DATENAME ( datepart ,date ) Returns a string that represents the specified datepart
DATEPART ( datepart ,date ) Returns an integer that represents the specified datepart
DAY ( date ) Returns an integer that represents the day part
MONTH ( date ) Returns an integer that represents the month part
YEAR ( date ) Returns an integer that represents the year part
DATEDIFF
( datepart ,startdate , enddate )
Returns the number of date or time datepart boundaries that are crossed
between two dates.
DATEADD (datepart , number, date )
Returns a new datetime value by adding an interval to the specified datepart of
the specified date.
End
-- Seyed Ibrahim --

More Related Content

What's hot

What's hot (14)

Synapseindia dot net development chapter 8 asp dot net
Synapseindia dot net development  chapter 8 asp dot netSynapseindia dot net development  chapter 8 asp dot net
Synapseindia dot net development chapter 8 asp dot net
 
VISUAL BASIC .net data accesss vii
VISUAL BASIC .net data accesss viiVISUAL BASIC .net data accesss vii
VISUAL BASIC .net data accesss vii
 
Query parameterization
Query parameterizationQuery parameterization
Query parameterization
 
Windowing functions session for Slovak SQL Pass & BI
Windowing functions session for Slovak SQL Pass & BIWindowing functions session for Slovak SQL Pass & BI
Windowing functions session for Slovak SQL Pass & BI
 
Using T-SQL
Using T-SQL Using T-SQL
Using T-SQL
 
Jdbc presentation
Jdbc presentationJdbc presentation
Jdbc presentation
 
5\9 SSIS 2008R2_Training - DataFlow Basics
5\9 SSIS 2008R2_Training - DataFlow Basics5\9 SSIS 2008R2_Training - DataFlow Basics
5\9 SSIS 2008R2_Training - DataFlow Basics
 
New T-SQL Features in SQL Server 2012
New T-SQL Features in SQL Server 2012 New T-SQL Features in SQL Server 2012
New T-SQL Features in SQL Server 2012
 
React&redux
React&reduxReact&redux
React&redux
 
SF Scala meet up, lighting talk: SPA -- Scala JDBC wrapper
SF Scala meet up, lighting talk: SPA -- Scala JDBC wrapperSF Scala meet up, lighting talk: SPA -- Scala JDBC wrapper
SF Scala meet up, lighting talk: SPA -- Scala JDBC wrapper
 
Oracle SQL Basics
Oracle SQL BasicsOracle SQL Basics
Oracle SQL Basics
 
Slickdemo
SlickdemoSlickdemo
Slickdemo
 
SQLCLR Tips & Trics
SQLCLR Tips & TricsSQLCLR Tips & Trics
SQLCLR Tips & Trics
 
2° Ciclo Microsoft CRUI 3° Sessione: l'evoluzione delle piattaforme tecnologi...
2° Ciclo Microsoft CRUI 3° Sessione: l'evoluzione delle piattaforme tecnologi...2° Ciclo Microsoft CRUI 3° Sessione: l'evoluzione delle piattaforme tecnologi...
2° Ciclo Microsoft CRUI 3° Sessione: l'evoluzione delle piattaforme tecnologi...
 

Similar to Sql server 2016: System Databases, data types, DML, json, and built-in functions

What's New for Developers in SQL Server 2008?
What's New for Developers in SQL Server 2008?What's New for Developers in SQL Server 2008?
What's New for Developers in SQL Server 2008?
ukdpe
 
Exciting Features for SQL Devs in SQL 2012
Exciting Features for SQL Devs in SQL 2012Exciting Features for SQL Devs in SQL 2012
Exciting Features for SQL Devs in SQL 2012
Brij Mishra
 
SQL.pptx for the begineers and good know
SQL.pptx for the begineers and good knowSQL.pptx for the begineers and good know
SQL.pptx for the begineers and good know
PavithSingh
 

Similar to Sql server 2016: System Databases, data types, DML, json, and built-in functions (20)

Ssn0020 ssis 2012 for beginners
Ssn0020   ssis 2012 for beginnersSsn0020   ssis 2012 for beginners
Ssn0020 ssis 2012 for beginners
 
dbs class 7.ppt
dbs class 7.pptdbs class 7.ppt
dbs class 7.ppt
 
3 CityNetConf - sql+c#=u-sql
3 CityNetConf - sql+c#=u-sql3 CityNetConf - sql+c#=u-sql
3 CityNetConf - sql+c#=u-sql
 
What's New for Developers in SQL Server 2008?
What's New for Developers in SQL Server 2008?What's New for Developers in SQL Server 2008?
What's New for Developers in SQL Server 2008?
 
SQL Server 2008 Overview
SQL Server 2008 OverviewSQL Server 2008 Overview
SQL Server 2008 Overview
 
2 sql - single-row functions
2   sql - single-row functions2   sql - single-row functions
2 sql - single-row functions
 
In memory databases presentation
In memory databases presentationIn memory databases presentation
In memory databases presentation
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
 
Module02
Module02Module02
Module02
 
SQL Functions
SQL FunctionsSQL Functions
SQL Functions
 
Die Neuheiten in MariaDB 10.2 und MaxScale 2.1
Die Neuheiten in MariaDB 10.2 und MaxScale 2.1Die Neuheiten in MariaDB 10.2 und MaxScale 2.1
Die Neuheiten in MariaDB 10.2 und MaxScale 2.1
 
Tk2323 lecture 7 sql
Tk2323 lecture 7   sql Tk2323 lecture 7   sql
Tk2323 lecture 7 sql
 
Ms sql-server
Ms sql-serverMs sql-server
Ms sql-server
 
PO WER - Piotr Mariat - Sql
PO WER - Piotr Mariat - SqlPO WER - Piotr Mariat - Sql
PO WER - Piotr Mariat - Sql
 
Exciting Features for SQL Devs in SQL 2012
Exciting Features for SQL Devs in SQL 2012Exciting Features for SQL Devs in SQL 2012
Exciting Features for SQL Devs in SQL 2012
 
Sql
SqlSql
Sql
 
SQL.pptx for the begineers and good know
SQL.pptx for the begineers and good knowSQL.pptx for the begineers and good know
SQL.pptx for the begineers and good know
 
03 2017Emea_RoadshowMilan-WhatsNew-Mariadbserver10_2andmaxscale 2_1
03 2017Emea_RoadshowMilan-WhatsNew-Mariadbserver10_2andmaxscale 2_103 2017Emea_RoadshowMilan-WhatsNew-Mariadbserver10_2andmaxscale 2_1
03 2017Emea_RoadshowMilan-WhatsNew-Mariadbserver10_2andmaxscale 2_1
 
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
 
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
 

Recently uploaded

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 

Recently uploaded (20)

VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 

Sql server 2016: System Databases, data types, DML, json, and built-in functions

  • 1. SQL Server 2016 System DBs, Data Types, DML, JSON, and Built-in Functions Seyed Ibrahim
  • 2. System DBs • master • All logins, or roles, to which the user IDs belong • Every system configuration setting (e.g.: data sorting information, security implementation, default language) • The names of and information about the databases within the server • The location of databases • How SQL Server is initialized • Several System tables - System error and warning messages, etc. • tempdb • lifetime is the duration of a SQL Server session • Temp tables
  • 3. System DBs • model • the basis for creating the tempdb database & any other database created • if you want all your databases to have a specific initial size or to have a specific set of information • msdb • provides the necessary information to run jobs to SQL Server Agent • SQL Server Agent: Windows service that runs any scheduled jobs
  • 4. Data Definition Language - CREATE • CREATE DATABASE • CREATE DEFAULT When bound to a column, specifies a value to be inserted • CREATE TABLE • CREATE VIEW • CREATE PROCEDURE Creates a T-SQL or common language runtime (CLR) SP • CREATE FUNCTION Creates a user-defined function in SQL Server • CREATE TRIGGER Creates a DML, DDL, or logon trigger • CREATE SEQUENCE Creates a sequence object and specifies its properties • CREATE LOGIN Creates a Database Engine login for SQL Server • CREATE ROLE Creates a new database role in the current database • CREATE USER Adds a user to the current database
  • 5. Login Vs User • With a login, you can connect to SQL Server • It cannot connect to any of the user databases • user is an account that is database-specific • a login cannot perform database actions without a valid user account • The two may have exactly the same name
  • 6. Data Types • Exact Numerics • Bigint (Trillions), int, smallint (-32k to +32k), tinyint • numeric, decimal – With precision and scale. Almost the same • bit • money, smallmoney – Not really used • Approximate Numerics • Float (application state depends on the implementation of the floating point numbers) • Real (same as Float(24))
  • 7. Data Types • Date and Time • Date 0001-01-01 through 9999-12-31 • Time 00:00:00.0000000 through 23:59:59.9999999 • Datetime January 1, 1753, through December 31, 9999 with Time • Smalldatetime 1900-01-01 through 2079-06-06 with 00:00:00 • Character Strings • Char Fixed-length, non-Unicode string data • Varchar Variable-length, non-Unicode string data • text Variable-length non-Unicode data (2^31 - 1)
  • 8. Data Types • Unicode Character Strings • Nchar Fixed-length Unicode string data • Nvarchar Variable-length Unicode string data • Ntext Variable-length Unicode data • Binary Strings • Binary Fixed-length binary data • Varbinary • Image Variable-length binary data (2,147,483,647 bytes)
  • 9. Data Manipulation Language • INSERT Syntax INSERT [INTO] {table_name|view_name} [{(column_name,column_name,…)}] {VALUES (expression, expression, …)} • BULK INSERT Example BULK INSERT Sales.SalesOrderDetail FROM 'computer2salesforcedailyordersneworders.txt';
  • 10. Data Manipulation Language • DELETE Syntax DELETE tablename WHERE where_condition • TRUNCATE TABLE Example • will delete data from a table with millions of records in only a few seconds • cannot issue it against tables that have foreign keys referencing them TRUNCATE TABLE CustomerDetails.Customers
  • 11. Data Manipulation Language • UPDATE UPDATE dbo.Customers SET FirstName = ‘Talha' WHERE CustomerId = 7 • MERGE • separate insert, update, and delete statements all within the same statement • A level above UPSERT: inserts rows that don't exist and updates the rows that do exist
  • 12. Types of Built-in Functions Rowset Functions Return an object that can be used like table references in an SQL statement OPENXML, OPENROWSET, OPENQUERY ( linked_server ,'query' ) , etc. Aggregate Functions Operate on a collection of values but return a single, summarizing value. AVG, MIN, MAX, COUNT, SUM, STDDEV, etc. Ranking Functions Return a ranking value for each row in a partition. RANK, DENSE_RANK, ROW_NUMBER Scalar Functions (Described Next) Operate on a single value and then return a single value. Scalar functions can be used wherever an expression is valid.
  • 13. Scalar Functions Function category Description & Examples Conversion Functions CAST and CONVERT - one data type to another Date and Time Data Types and Functions Perform operations on a date and time input values and return string, numeric, or date and time values. JSON Functions Validate, query, or change JSON data. Logical Functions CHOOSE ( index, val_1, val_2,..) , IIF ( boolean_expression, true_value, false_value ) Mathematical Functions Perform calculations based on input values provided as parameters to the functions, and return numeric values. Metadata Functions Return information about the database and database objects. String Functions LEFT, RIGHT, SUBSTRING, UPPER, LOWER, CONCAT, RTRIM, LTRIM, ETC. System Functions Perform operations and return information about values, objects, and settings. HOST_NAME, ISNULL, ISNUMERIC, @@ROWCOUNT, ERROR_NUMBER, etc
  • 14. JSON in SQL 2016
  • 15. JSON Functions Function Description ISJSON Tests whether a string contains valid JSON. JSON_VALUE Extracts a scalar value from a JSON string. JSON_QUERY Extracts an object or an array from a JSON string. JSON_MODIFY Updates the value of a property in a JSON string and returns the updated JSON string
  • 16. Date and Time Functions Syntax Return value SYSDATETIME () & GETDATE ( ) date and time of the computer on which the instance of SQL Server is running SYSUTCDATETIME ( ) & GETUTCDATE ( ) The date and time is returned as UTC time (Coordinated Universal Time). DATENAME ( datepart ,date ) Returns a string that represents the specified datepart DATEPART ( datepart ,date ) Returns an integer that represents the specified datepart DAY ( date ) Returns an integer that represents the day part MONTH ( date ) Returns an integer that represents the month part YEAR ( date ) Returns an integer that represents the year part DATEDIFF ( datepart ,startdate , enddate ) Returns the number of date or time datepart boundaries that are crossed between two dates. DATEADD (datepart , number, date ) Returns a new datetime value by adding an interval to the specified datepart of the specified date.