Thursday, 25 June 2015

Microsoft Azure SQL Data Warehouse Overview



With Azure, you can also have SQL Server Data Warehouses. This is a great idea if your environment is several gigabits large and you want to be able to increase processing power without installing new hardware.

Just watch this video to find out more

Wednesday, 24 June 2015

Microsoft Azure SQL Database Overview



With SQL Server 2016 , it now has the ability to stretch your database to the cloud to a Microsoft Azure SQL Database.

Stretching your database gives you the ability to have some of your data locally within your business and some of your database placed in the cloud which is accessible worldwide.

There are many benefits of putting your databases in the cloud and to see a great overview of what Microsoft Azure SQL Database can do, just watch this video.


Tuesday, 23 June 2015

In-memory OLTP in SQL Server

If you want to know a lot of information about in-memory OLTP in SQL Server, then watch these two videos. They both explain how and when to use in-memory technology within your environment.


An overview of in-memory OLTP in SQL Server 2014
 

Microsoft SQL Server 2014: In-Memory OLTP for Database Developers






Friday, 19 June 2015

Operational Analytics - SQL Server 2016




With SQL Server 2016, there is now the ability to have operational analytics on OLTP systems.

This is a great idea and watch the video below to find out more.

Wednesday, 17 June 2015

Temporal in SQL Server 2016 - Creating/Querying Tables


Below are two example on how to create Temporal tables in SQL Server 2016
They will both store histroic information on data that gets into the table

-- A History table is not specified
CREATE TABLE dbo.Customer
(
    CustomerID        int NOT NULL IDENTITY(1,1) PRIMARY KEY CLUSTERED,
    CustomerName      varchar(50) NOT NULL,

    ValidFrom           datetime2 GENERATED ALWAYS AS ROW START NOT NULL,
    ValidTo             datetime2 GENERATED ALWAYS AS ROW END   NOT NULL,  

    PERIOD FOR SYSTEM_TIME (
        ValidFrom,
        ValidTo
    )  
)
WITH ( SYSTEM_VERSIONING = ON );
GO


-- A History table is specified
CREATE TABLE dbo.Customer
(
    CustomerID        int NOT NULL IDENTITY(1,1) PRIMARY KEY CLUSTERED,
    CustomerName      varchar(50) NOT NULL,

    ValidFrom           datetime2 GENERATED ALWAYS AS ROW START NOT NULL,
    ValidTo             datetime2 GENERATED ALWAYS AS ROW END   NOT NULL,  

    PERIOD FOR SYSTEM_TIME (
        ValidFrom,
        ValidTo
    )  
)
WITH ( SYSTEM_VERSIONING = ON (HISTORY_TABLE = dbo.CustomerHistory) );
GO


To query Temporal tables, you can use the code below. The code below will automatically look in the CustomerHistory table if its not in the Customer table.

SELECT * FROM dbo.Customer FOR SYSTEM_TIME AS OF '2015-1-1'

Temporal Tables Limitations

* Usage of Replication technologies is limited.
* INSERT and UPDATE statements cannot reference the SYSTEM_TIME period columns.
* Direct modification of the data in a history table is not permitted.
* Temporal querying over Linked Server is not supported.
* History table cannot have constraints (PK, FK, Table or Column constraints).
* TRUNCATE TABLE is not supported while SYSTEM_VERSIONING is ON
* INSTEAD OF triggers are not permitted on either the tables.


Tuesday, 16 June 2015

Temporal in SQL Server 2016


Well I am so looking forward to using Temporal in SQL Server 2016, the ability to track changes in a table without creating triggers and custom history tables in a ad-hoc way sounds awesome.

Watch the video below to see how it works.


Monday, 15 June 2015

SQL Server 2016 - Extended Events - Deadlocks Tracking

Below is some code to track deadlocks in your server using Extended Events

CREATE EVENT SESSION [Deadlock Tracking] ON SERVER 
ADD EVENT sqlserver.xml_deadlock_report(
    ACTION(sqlos.task_time,sqlos.worker_address,sqlserver.client_hostname,sqlserver.client_pid,sqlserver.database_id,sqlserver.database_name,sqlserver.sql_text,sqlserver.transaction_id,sqlserver.transaction_sequence,sqlserver.username)) 
ADD TARGET package0.ring_buffer(SET max_memory=(102400))
WITH (MAX_MEMORY=4096 KB,EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,MAX_DISPATCH_LATENCY=30 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=NONE,TRACK_CAUSALITY=OFF,STARTUP_STATE=OFF)
GO

Deadlock tracking is already tracked under the default 'system_health' Session, but if you just wanted  just to track deadlocks by itself, then the above code will work.

Once a deadlock occurs, it will produce a graph like the following so that you can investigate the problem further. 



You can also hover over the symbols to get more information about the deadlocks.