SlideShare a Scribd company logo
SQL Server 2016 –
Some New Features
@anniexu1990
Agenda
• IF EXISTS
• Text Split
• TemporalTables
• Column stored indexes
IF EXISTS
--in versions before 2016
IF OBJECT_ID('[dbo].[V_319AdHocObjects]') IS NOT NULL
BEGIN
DROPVIEW [dbo].[V_319AdHocObjects];
END;
GO
CREATEVIEW [dbo].[V_319AdHocObjects]
AS
SELECT name AS object_name,
SCHEMA_NAME(schema_id) AS schema_name,
x.type_desc
FROM sys.objects x
LEFT JOIN sys.dm_exec_procedure_statsAS d ON
OBJECT_NAME(d.object_id, d.database_id) = name
WHERE SCHEMA_NAME(schema_id) <> 'sys';
--in versions 2016
DROPVIEW IF EXISTS [dbo].[V_319AdHocObjects];
GO
CREATEVIEW [dbo].[V_319AdHocObjects]
AS
SELECT name AS object_name,
SCHEMA_NAME(schema_id) AS schema_name,
x.type_desc
FROM sys.objects x
LEFT JOIN sys.dm_exec_procedure_statsAS d ON
OBJECT_NAME(d.object_id, d.database_id) = name
WHERE SCHEMA_NAME(schema_id) <> 'sys';
TEXT Split
SELECT [ID],
[REPORTING_SEGMENT]
FROM [Ad_Hoc].[dbo].[Service_Requests];
-- use 2016 new scirpt string_split to get number of IDs per reporting_Setment
SELECT value AS reporting_seg,
COUNT([ID])AS countofrequests
FROM [Ad_Hoc].[dbo].[Service_Requests]
CROSS APPLY string_split([REPORTING_SEGMENT], ',')
GROUP BY value;
TemporalTables
USE [Ad_Hoc]
GO
CREATETABLE [dbo].[DataAccuracy_GPM_Temporal](
[ID] int Identity(1,1) Primary Key,
[DataType] [varchar](20) NULL,
[System Name] [varchar](20) NULL,
[Date] [date] NULL,
[Model Field] [nvarchar](255) NULL,
[SourceValue] [money] NULL,
[GPTValue] [money] NULL,
[ModelValue] [decimal](14, 2) NULL
,SysStartTime datetime2GENERATEDALWAYS AS ROW
START HIDDEN NOT NULL
,SysEndTime datetime2GENERATEDALWAYS AS ROW
END HIDDEN NOT NULL
,PERIOD FOR SYSTEM_TIME (SysStartTime,SysEndTime))
WITH (SYSTEM_VERSIONING = ON
(HISTORY_TABLE=dbo.DataAccuracy_GPM_History));
Select [ID]
,[DataType]
,[System Name]
,[Date]
,[Model Field]
,[SourceValue]
,[GPTValue]
,[ModelValue]
,[SysStartTime]
,[SysEndTime]
--ChangeTimezone
--,convert(smalldatetime,[SysStartTime]ATTIME ZONE
'UTC'ATTIME ZONE 'Eastern StandardTime') as
'SystemStartTimeEST'
--,Case when [SysEndTime] = '9999-12-31
23:59:59.9999999' then [SysEndTime]ATTIME ZONE 'UTC'
--ELSE convert(smalldatetime, [SysEndTime]ATTIME
ZONE 'UTC'ATTIME ZONE 'Eastern StandardTime') end as
'SystemEndTimeEST'
from [dbo].[DataAccuracy_GPM_Temporal]
-- For SYSTEM_TIME FROM '2017-06-05 19:12:45.8094962'
to '2017-06-05 19:18:45.8094962'
-- For SYSTEM_TIME CONTAINED IN ( '2017-06-05
19:12:45.8094962', '2017-06-05 19:18:45.8094962')
Columnstore Indexes
--create normal rowstore index
CREATECLUSTERED INDEX [ClusteredIndex-RequestID]ON
[dbo].[Service_Requests_NormalIndex];
GO
--result normal index remember to show plan
SET STATISTICSTIME ON
SELECT [REQ_TYPE]
,count([ID])
FROM [Ad_Hoc].[dbo].[Service_Requests_NormalIndex]
group by [REQ_TYPE];
SET STATISTICSTIME OFF
go
-- create columnstore index
CREATECLUSTERED COLUMNSTORE INDEX [SR_ColumnStoreIndex]
ON Service_Requests_ColumnStoreIndex;
GO
--result
SET STATISTICSTIME ON
SELECT [REQ_TYPE]
,count([ID])
FROM [Ad_Hoc].[dbo].[Service_Requests_ColumnStoreIndex]
group by [REQ_TYPE];
SET STATISTICSTIME OFF
go

More Related Content

Similar to Sql server 2016 – some new features

DNN Database Tips & Tricks
DNN Database Tips & TricksDNN Database Tips & Tricks
DNN Database Tips & Tricks
Will Strohl
 
Database Systems - SQL - DDL Statements (Chapter 3/2)
Database Systems - SQL - DDL Statements (Chapter 3/2)Database Systems - SQL - DDL Statements (Chapter 3/2)
Database Systems - SQL - DDL Statements (Chapter 3/2)
Vidyasagar Mundroy
 
supporting t-sql scripts for Heap vs clustered table
supporting t-sql scripts for Heap vs clustered tablesupporting t-sql scripts for Heap vs clustered table
supporting t-sql scripts for Heap vs clustered table
Mahabubur Rahaman
 
171_74_216_Module_5-Non_relational_database_-mongodb.pptx
171_74_216_Module_5-Non_relational_database_-mongodb.pptx171_74_216_Module_5-Non_relational_database_-mongodb.pptx
171_74_216_Module_5-Non_relational_database_-mongodb.pptx
sukrithlal008
 
SAS Internal Training
SAS Internal TrainingSAS Internal Training
SAS Internal Training
Amrih Muktiaji
 
I am getting an errormsg 911, Level 16, State 1, Line 12 Database.pdf
I am getting an errormsg 911, Level 16, State 1, Line 12 Database.pdfI am getting an errormsg 911, Level 16, State 1, Line 12 Database.pdf
I am getting an errormsg 911, Level 16, State 1, Line 12 Database.pdf
irshadkumar3
 
Using web2py's DAL in other projects or frameworks
Using web2py's DAL in other projects or frameworksUsing web2py's DAL in other projects or frameworks
Using web2py's DAL in other projects or frameworks
Bruno Rocha
 
Mysql rab2-student
Mysql rab2-studentMysql rab2-student
Mysql rab2-student
santosh mishra
 
Mysql rab2-student
Mysql rab2-studentMysql rab2-student
Mysql rab2-student
santosh mishra
 
Designer's Favorite New Features in SQLServer
Designer's Favorite New Features in SQLServerDesigner's Favorite New Features in SQLServer
Designer's Favorite New Features in SQLServer
Karen Lopez
 
Msql
Msql Msql
Msql
ksujitha
 
Planning with Polyalgebra: Bringing Together Relational, Complex and Machine ...
Planning with Polyalgebra: Bringing Together Relational, Complex and Machine ...Planning with Polyalgebra: Bringing Together Relational, Complex and Machine ...
Planning with Polyalgebra: Bringing Together Relational, Complex and Machine ...
Julian Hyde
 
Polyalgebra
PolyalgebraPolyalgebra
MongoDB + Java - Everything you need to know
MongoDB + Java - Everything you need to know MongoDB + Java - Everything you need to know
MongoDB + Java - Everything you need to know
Norberto Leite
 
Mongo+java (1)
Mongo+java (1)Mongo+java (1)
Mongo+java (1)
MongoDB
 
Micro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicateMicro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicate
Kiev ALT.NET
 
Neo4j: Import and Data Modelling
Neo4j: Import and Data ModellingNeo4j: Import and Data Modelling
Neo4j: Import and Data Modelling
Neo4j
 
When to NoSQL and when to know SQL
When to NoSQL and when to know SQLWhen to NoSQL and when to know SQL
When to NoSQL and when to know SQL
Simon Elliston Ball
 
Couchbas for dummies
Couchbas for dummiesCouchbas for dummies
Couchbas for dummies
Qureshi Tehmina
 
Nko workshop - node js & nosql
Nko workshop - node js & nosqlNko workshop - node js & nosql
Nko workshop - node js & nosql
Simon Su
 

Similar to Sql server 2016 – some new features (20)

DNN Database Tips & Tricks
DNN Database Tips & TricksDNN Database Tips & Tricks
DNN Database Tips & Tricks
 
Database Systems - SQL - DDL Statements (Chapter 3/2)
Database Systems - SQL - DDL Statements (Chapter 3/2)Database Systems - SQL - DDL Statements (Chapter 3/2)
Database Systems - SQL - DDL Statements (Chapter 3/2)
 
supporting t-sql scripts for Heap vs clustered table
supporting t-sql scripts for Heap vs clustered tablesupporting t-sql scripts for Heap vs clustered table
supporting t-sql scripts for Heap vs clustered table
 
171_74_216_Module_5-Non_relational_database_-mongodb.pptx
171_74_216_Module_5-Non_relational_database_-mongodb.pptx171_74_216_Module_5-Non_relational_database_-mongodb.pptx
171_74_216_Module_5-Non_relational_database_-mongodb.pptx
 
SAS Internal Training
SAS Internal TrainingSAS Internal Training
SAS Internal Training
 
I am getting an errormsg 911, Level 16, State 1, Line 12 Database.pdf
I am getting an errormsg 911, Level 16, State 1, Line 12 Database.pdfI am getting an errormsg 911, Level 16, State 1, Line 12 Database.pdf
I am getting an errormsg 911, Level 16, State 1, Line 12 Database.pdf
 
Using web2py's DAL in other projects or frameworks
Using web2py's DAL in other projects or frameworksUsing web2py's DAL in other projects or frameworks
Using web2py's DAL in other projects or frameworks
 
Mysql rab2-student
Mysql rab2-studentMysql rab2-student
Mysql rab2-student
 
Mysql rab2-student
Mysql rab2-studentMysql rab2-student
Mysql rab2-student
 
Designer's Favorite New Features in SQLServer
Designer's Favorite New Features in SQLServerDesigner's Favorite New Features in SQLServer
Designer's Favorite New Features in SQLServer
 
Msql
Msql Msql
Msql
 
Planning with Polyalgebra: Bringing Together Relational, Complex and Machine ...
Planning with Polyalgebra: Bringing Together Relational, Complex and Machine ...Planning with Polyalgebra: Bringing Together Relational, Complex and Machine ...
Planning with Polyalgebra: Bringing Together Relational, Complex and Machine ...
 
Polyalgebra
PolyalgebraPolyalgebra
Polyalgebra
 
MongoDB + Java - Everything you need to know
MongoDB + Java - Everything you need to know MongoDB + Java - Everything you need to know
MongoDB + Java - Everything you need to know
 
Mongo+java (1)
Mongo+java (1)Mongo+java (1)
Mongo+java (1)
 
Micro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicateMicro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicate
 
Neo4j: Import and Data Modelling
Neo4j: Import and Data ModellingNeo4j: Import and Data Modelling
Neo4j: Import and Data Modelling
 
When to NoSQL and when to know SQL
When to NoSQL and when to know SQLWhen to NoSQL and when to know SQL
When to NoSQL and when to know SQL
 
Couchbas for dummies
Couchbas for dummiesCouchbas for dummies
Couchbas for dummies
 
Nko workshop - node js & nosql
Nko workshop - node js & nosqlNko workshop - node js & nosql
Nko workshop - node js & nosql
 

Recently uploaded

System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
Hiike
 
SAP S/4 HANA sourcing and procurement to Public cloud
SAP S/4 HANA sourcing and procurement to Public cloudSAP S/4 HANA sourcing and procurement to Public cloud
SAP S/4 HANA sourcing and procurement to Public cloud
maazsz111
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
ScyllaDB
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
LucaBarbaro3
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Tatiana Kojar
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
Miro Wengner
 

Recently uploaded (20)

System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
 
SAP S/4 HANA sourcing and procurement to Public cloud
SAP S/4 HANA sourcing and procurement to Public cloudSAP S/4 HANA sourcing and procurement to Public cloud
SAP S/4 HANA sourcing and procurement to Public cloud
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
 

Sql server 2016 – some new features

  • 1. SQL Server 2016 – Some New Features @anniexu1990
  • 2. Agenda • IF EXISTS • Text Split • TemporalTables • Column stored indexes
  • 3. IF EXISTS --in versions before 2016 IF OBJECT_ID('[dbo].[V_319AdHocObjects]') IS NOT NULL BEGIN DROPVIEW [dbo].[V_319AdHocObjects]; END; GO CREATEVIEW [dbo].[V_319AdHocObjects] AS SELECT name AS object_name, SCHEMA_NAME(schema_id) AS schema_name, x.type_desc FROM sys.objects x LEFT JOIN sys.dm_exec_procedure_statsAS d ON OBJECT_NAME(d.object_id, d.database_id) = name WHERE SCHEMA_NAME(schema_id) <> 'sys'; --in versions 2016 DROPVIEW IF EXISTS [dbo].[V_319AdHocObjects]; GO CREATEVIEW [dbo].[V_319AdHocObjects] AS SELECT name AS object_name, SCHEMA_NAME(schema_id) AS schema_name, x.type_desc FROM sys.objects x LEFT JOIN sys.dm_exec_procedure_statsAS d ON OBJECT_NAME(d.object_id, d.database_id) = name WHERE SCHEMA_NAME(schema_id) <> 'sys';
  • 4. TEXT Split SELECT [ID], [REPORTING_SEGMENT] FROM [Ad_Hoc].[dbo].[Service_Requests]; -- use 2016 new scirpt string_split to get number of IDs per reporting_Setment SELECT value AS reporting_seg, COUNT([ID])AS countofrequests FROM [Ad_Hoc].[dbo].[Service_Requests] CROSS APPLY string_split([REPORTING_SEGMENT], ',') GROUP BY value;
  • 5. TemporalTables USE [Ad_Hoc] GO CREATETABLE [dbo].[DataAccuracy_GPM_Temporal]( [ID] int Identity(1,1) Primary Key, [DataType] [varchar](20) NULL, [System Name] [varchar](20) NULL, [Date] [date] NULL, [Model Field] [nvarchar](255) NULL, [SourceValue] [money] NULL, [GPTValue] [money] NULL, [ModelValue] [decimal](14, 2) NULL ,SysStartTime datetime2GENERATEDALWAYS AS ROW START HIDDEN NOT NULL ,SysEndTime datetime2GENERATEDALWAYS AS ROW END HIDDEN NOT NULL ,PERIOD FOR SYSTEM_TIME (SysStartTime,SysEndTime)) WITH (SYSTEM_VERSIONING = ON (HISTORY_TABLE=dbo.DataAccuracy_GPM_History)); Select [ID] ,[DataType] ,[System Name] ,[Date] ,[Model Field] ,[SourceValue] ,[GPTValue] ,[ModelValue] ,[SysStartTime] ,[SysEndTime] --ChangeTimezone --,convert(smalldatetime,[SysStartTime]ATTIME ZONE 'UTC'ATTIME ZONE 'Eastern StandardTime') as 'SystemStartTimeEST' --,Case when [SysEndTime] = '9999-12-31 23:59:59.9999999' then [SysEndTime]ATTIME ZONE 'UTC' --ELSE convert(smalldatetime, [SysEndTime]ATTIME ZONE 'UTC'ATTIME ZONE 'Eastern StandardTime') end as 'SystemEndTimeEST' from [dbo].[DataAccuracy_GPM_Temporal] -- For SYSTEM_TIME FROM '2017-06-05 19:12:45.8094962' to '2017-06-05 19:18:45.8094962' -- For SYSTEM_TIME CONTAINED IN ( '2017-06-05 19:12:45.8094962', '2017-06-05 19:18:45.8094962')
  • 6. Columnstore Indexes --create normal rowstore index CREATECLUSTERED INDEX [ClusteredIndex-RequestID]ON [dbo].[Service_Requests_NormalIndex]; GO --result normal index remember to show plan SET STATISTICSTIME ON SELECT [REQ_TYPE] ,count([ID]) FROM [Ad_Hoc].[dbo].[Service_Requests_NormalIndex] group by [REQ_TYPE]; SET STATISTICSTIME OFF go -- create columnstore index CREATECLUSTERED COLUMNSTORE INDEX [SR_ColumnStoreIndex] ON Service_Requests_ColumnStoreIndex; GO --result SET STATISTICSTIME ON SELECT [REQ_TYPE] ,count([ID]) FROM [Ad_Hoc].[dbo].[Service_Requests_ColumnStoreIndex] group by [REQ_TYPE]; SET STATISTICSTIME OFF go