diff --git a/samples/features/columnstore/InMemoryColumnstore/hk_cs_dmvs.sql b/samples/features/columnstore/InMemoryColumnstore/hk_cs_dmvs.sql
new file mode 100644
index 00000000..7938175f
--- /dev/null
+++ b/samples/features/columnstore/InMemoryColumnstore/hk_cs_dmvs.sql
@@ -0,0 +1,80 @@
+USE MASTER
+
+-- show memory DMVs
+/*
+SELECT name
+FROM sys.system_objects
+WHERE name LIKE '%xtp%memory%'
+ ORDER BY name
+ */
+
+
+ select committed_kb, committed_target_kb
+from sys.dm_os_sys_info
+
+select pool_id,convert(char(30), name) as Name, min_memory_percent, max_memory_percent, max_memory_kb/1024 as max_memory_in_MB, used_memory_kb/1024 as used_memory_in_MB,
+target_memory_kb/1024 as target_memory_in_MB
+from sys.dm_resource_governor_resource_pools
+
+
+select convert(char(20), object_name(object_id)) as Name,*
+from sys.dm_db_xtp_table_memory_stats
+where object_id> 0
+
+-- Memory in MB
+select Sum( memory_allocated_for_indexes_kb + memory_allocated_for_table_kb)/1024 as
+ memoryallocated_objects_in_mb,
+ Sum( memory_used_by_indexes_kb + memory_used_by_table_kb)/1024 as
+ memoryused_objects_in_mb
+from sys.dm_db_xtp_table_memory_stats
+
+-- consumer memory
+select convert(char(20), object_name(object_id)) as Name, *
+from sys.dm_db_xtp_memory_consumers
+
+select sum(allocated_bytes)/(1024*1024) as total_allocated_MB, sum(used_bytes)/(1024*1024) as total_used_MB
+from sys.dm_db_xtp_memory_consumers
+
+select * from sys.dm_xtp_system_memory_consumers
+select sum(allocated_bytes)/(1024*1024) as total_allocated_MB, sum(used_bytes)/(1024*1024) as total_used_MB
+from sys.dm_xtp_system_memory_consumers
+
+
+select type, name, memory_node_id, pages_kb/1024 as pages_MB
+from sys.dm_os_memory_clerks
+where type like '%xtp%'
+
+
+select type, sum(pages_in_bytes/1024) as size_kb
+from sys.dm_os_memory_objects
+where type like '%xtp%'
+group by type
+
+
+select sum(pages_in_bytes)/(1024*1024) as pages_in_MB
+from sys.dm_os_memory_objects where type like '%xtp%'
+select *
+from sys.dm_os_memory_objects where type like '%xtp%'
+
+
+-- SUMS
+
+select Sum( memory_allocated_for_indexes_kb + memory_allocated_for_table_kb)/1024 as
+ memoryallocated_objects_in_mb,
+ Sum( memory_used_by_indexes_kb + memory_used_by_table_kb)/1024 as
+ memoryused_objects_in_mb
+from sys.dm_db_xtp_table_memory_stats
+select sum(allocated_bytes)/(1024*1024) as total_allocated_MB, sum(used_bytes)/(1024*1024) as total_used_MB
+from sys.dm_db_xtp_memory_consumers
+
+select sum(allocated_bytes)/(1024*1024) as total_allocated_MB, sum(used_bytes)/(1024*1024) as total_used_MB
+from sys.dm_xtp_system_memory_consumers
+select type, name, memory_node_id, pages_kb/1024 as pages_MB
+from sys.dm_os_memory_clerks
+where type like '%xtp%'
+
+
+select type, sum(pages_in_bytes/1024) as size_kb
+from sys.dm_os_memory_objects
+where type like '%xtp%'
+group by type
\ No newline at end of file
diff --git a/samples/features/columnstore/InMemoryColumnstore/hk_memory_dmvs.sql b/samples/features/columnstore/InMemoryColumnstore/hk_memory_dmvs.sql
new file mode 100644
index 00000000..7938175f
--- /dev/null
+++ b/samples/features/columnstore/InMemoryColumnstore/hk_memory_dmvs.sql
@@ -0,0 +1,80 @@
+USE MASTER
+
+-- show memory DMVs
+/*
+SELECT name
+FROM sys.system_objects
+WHERE name LIKE '%xtp%memory%'
+ ORDER BY name
+ */
+
+
+ select committed_kb, committed_target_kb
+from sys.dm_os_sys_info
+
+select pool_id,convert(char(30), name) as Name, min_memory_percent, max_memory_percent, max_memory_kb/1024 as max_memory_in_MB, used_memory_kb/1024 as used_memory_in_MB,
+target_memory_kb/1024 as target_memory_in_MB
+from sys.dm_resource_governor_resource_pools
+
+
+select convert(char(20), object_name(object_id)) as Name,*
+from sys.dm_db_xtp_table_memory_stats
+where object_id> 0
+
+-- Memory in MB
+select Sum( memory_allocated_for_indexes_kb + memory_allocated_for_table_kb)/1024 as
+ memoryallocated_objects_in_mb,
+ Sum( memory_used_by_indexes_kb + memory_used_by_table_kb)/1024 as
+ memoryused_objects_in_mb
+from sys.dm_db_xtp_table_memory_stats
+
+-- consumer memory
+select convert(char(20), object_name(object_id)) as Name, *
+from sys.dm_db_xtp_memory_consumers
+
+select sum(allocated_bytes)/(1024*1024) as total_allocated_MB, sum(used_bytes)/(1024*1024) as total_used_MB
+from sys.dm_db_xtp_memory_consumers
+
+select * from sys.dm_xtp_system_memory_consumers
+select sum(allocated_bytes)/(1024*1024) as total_allocated_MB, sum(used_bytes)/(1024*1024) as total_used_MB
+from sys.dm_xtp_system_memory_consumers
+
+
+select type, name, memory_node_id, pages_kb/1024 as pages_MB
+from sys.dm_os_memory_clerks
+where type like '%xtp%'
+
+
+select type, sum(pages_in_bytes/1024) as size_kb
+from sys.dm_os_memory_objects
+where type like '%xtp%'
+group by type
+
+
+select sum(pages_in_bytes)/(1024*1024) as pages_in_MB
+from sys.dm_os_memory_objects where type like '%xtp%'
+select *
+from sys.dm_os_memory_objects where type like '%xtp%'
+
+
+-- SUMS
+
+select Sum( memory_allocated_for_indexes_kb + memory_allocated_for_table_kb)/1024 as
+ memoryallocated_objects_in_mb,
+ Sum( memory_used_by_indexes_kb + memory_used_by_table_kb)/1024 as
+ memoryused_objects_in_mb
+from sys.dm_db_xtp_table_memory_stats
+select sum(allocated_bytes)/(1024*1024) as total_allocated_MB, sum(used_bytes)/(1024*1024) as total_used_MB
+from sys.dm_db_xtp_memory_consumers
+
+select sum(allocated_bytes)/(1024*1024) as total_allocated_MB, sum(used_bytes)/(1024*1024) as total_used_MB
+from sys.dm_xtp_system_memory_consumers
+select type, name, memory_node_id, pages_kb/1024 as pages_MB
+from sys.dm_os_memory_clerks
+where type like '%xtp%'
+
+
+select type, sum(pages_in_bytes/1024) as size_kb
+from sys.dm_os_memory_objects
+where type like '%xtp%'
+group by type
\ No newline at end of file
diff --git a/samples/features/columnstore/InMemoryColumnstore/hkcs-demo.sql b/samples/features/columnstore/InMemoryColumnstore/hkcs-demo.sql
new file mode 100644
index 00000000..9010ac05
--- /dev/null
+++ b/samples/features/columnstore/InMemoryColumnstore/hkcs-demo.sql
@@ -0,0 +1,138 @@
+
+USE [master]
+GO
+
+DROP DATABASE IF EXISTS [imoltp]
+GO
+
+CREATE DATABASE [imoltp]
+ CONTAINMENT = NONE
+ ON PRIMARY
+( NAME = N'imoltp_data', FILENAME = N'C:\data\imoltp_Data.mdf' , SIZE = 102400KB , MAXSIZE = 5GB, FILEGROWTH = 1024000KB )
+ LOG ON
+( NAME = N'imoltp_log', FILENAME = N'C:\data\imoltp_Log.ldf ' , SIZE = 52400KB , MAXSIZE = 5GB , FILEGROWTH = 102400KB )
+GO
+
+
+ALTER DATABASE imoltp ADD FILEGROUP imoltp_mod CONTAINS MEMORY_OPTIMIZED_DATA
+ALTER DATABASE imoltp ADD FILE (name='imoltp_mod', filename='c:\data\imoltp_mod') TO FILEGROUP imoltp_mod
+GO
+
+
+-- drop the database with
+-- pool management
+DROP RESOURCE POOL Poolimoltp
+go
+
+
+ALTER RESOURCE GOVERNOR RECONFIGURE;
+GO
+
+-- create the resoure pool
+CREATE RESOURCE POOL Poolimoltp WITH (MAX_MEMORY_PERCENT = 80);
+ALTER RESOURCE GOVERNOR RECONFIGURE;
+go
+
+-- bind the database to the pool
+EXEC sp_xtp_bind_db_resource_pool 'imoltp', 'Poolimoltp'
+go
+
+-- take database offline/online to associate the pool
+use master
+go
+
+alter database imoltp set offline WITH ROLLBACK IMMEDIATE
+go
+alter database imoltp set online
+go
+
+
+use imoltp
+go
+
+drop table if exists dbo.t_colstor_hk
+
+-- create a memopt table
+CREATE TABLE dbo.t_colstor_hk (
+ accountkey int not null,
+ accountdescription nvarchar (50),
+ accounttype nvarchar(50),
+ unitsold int,
+ CONSTRAINT [pk_t_colstor_hk] PRIMARY KEY NONCLUSTERED HASH (accountkey) WITH (BUCKET_COUNT = 10000000)--,
+-- index t_colstor_hk_cci clustered columnstore with (compression_delay=70)
+) WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_AND_DATA)
+go
+
+--you can add index after creating HK table (New in SQL 2016)
+alter table t_colstor_hk add index t_colstor_hk_cci clustered columnstore with (compression_delay=0)
+
+--this is not supported
+-- alter table t_colstor_hk alter index t_colstor_hk_cci set compression_delay=60
+
+--look at index definition
+select name, index_id, type_desc, compression_delay from sys.indexes where object_id = object_id('t_colstor_hk')
+
+
+set nocount on
+go
+
+set statistics time off
+go
+
+set statistics IO Off
+go
+--insert 4 million rows
+declare @outerloop int = 0
+declare @i int = 0
+while (@outerloop < 4000000)
+begin
+ Select @i = 0
+
+ begin tran
+ while (@i < 2000)
+ begin
+ insert t_colstor_hk values (@i + @outerloop, 'test1', 'test2', @i)
+ set @i += 1;
+ end
+ commit
+
+ set @outerloop = @outerloop + @i
+ set @i = 0
+end
+
+go
+select count(*) from t_colstor_hk
+
+-- look at the rowgroups
+select object_name(object_id), index_id, row_group_id, delta_store_hobt_id, state_desc, total_rows, size_in_bytes, trim_reason, trim_reason_desc, transition_to_compressed_state_desc
+from sys.dm_db_column_store_row_group_physical_stats
+where object_id = object_id('t_colstor_hk')
+
+-- run spec proc to move rows from delta tail
+-- The procedure takes two arguements: object_id and bit indicating whether migration policy should be evaluated.
+-- If you set migration policy to 0, as above, migration happens regardless of policy (ie. whether or not data is cold).
+declare @oid int = object_id('t_colstor_hk')
+exec sp_memory_optimized_cs_migration @oid
+go
+
+
+
+
+set statistics time on
+go
+
+
+set transaction isolation level read committed
+
+use imoltp
+go
+
+
+--compare the query performance
+select avg (convert (bigint, unitsold))
+from t_colstor_hk
+
+
+select avg (convert (bigint, unitsold))
+from t_colstor_hk with (index = [pk_t_colstor_hk])
+
diff --git a/samples/features/columnstore/NonclusteredColumnstore/compression-delay-setup.sql b/samples/features/columnstore/NonclusteredColumnstore/compression-delay-setup.sql
new file mode 100644
index 00000000..599fda39
--- /dev/null
+++ b/samples/features/columnstore/NonclusteredColumnstore/compression-delay-setup.sql
@@ -0,0 +1,124 @@
+create database columnstore
+go
+
+use columnstore
+go
+
+drop table staging
+go
+
+-- create staging table
+ Create table staging (
+ accountkey int not null,
+ accountdescription nvarchar (50),
+ accounttype nvarchar(50),
+ AccountCodeAlternatekey int)
+
+
+set nocount ON
+go
+
+-- load data into staging table
+ declare @loop int
+ declare @accountdescription varchar(50)
+ declare @accountkey int
+ declare @accounttype varchar(50)
+ declare @accountcode int
+
+
+ select @loop = 0
+ begin tran
+ while (@loop < 100000)
+ begin
+ select @accountkey = @loop
+ select @accountdescription = 'accountdesc ' + convert(varchar(20), @accountkey)
+ select @accounttype = 'accounttype ' + convert(varchar(20), @accountkey)
+ select @accountcode = cast (rand()*10000000 as int)
+
+
+ insert into staging values (@accountkey, @accountdescription, @accounttype, @AccountCode)
+
+ select @loop = @loop + 1
+ end
+ commit
+
+
+select count(*) from staging
+go
+
+drop table ncci_target, ncci_target_delay
+go
+
+dbcc tracestatus
+
+create table ncci_target (
+ accountkey int not null,
+ accountdescription nvarchar (50),
+ accounttype nvarchar(50),
+ AccountCodeAlternatekey int)
+
+create clustered index idx_ci_ncci_target on ncci_target (accountkey)
+create nonclustered columnstore index idxncci_ncci_target on
+ ncci_target (accountkey, accountdescription, accounttype, accountcodealternatekey)
+ with (compression_delay= 0)
+
+
+
+-- create another table with the delay of 30 seconds
+create table ncci_target_delay (
+ accountkey int not null,
+ accountdescription nvarchar (50),
+ accounttype nvarchar(50),
+ AccountCodeAlternatekey int)
+
+create clustered index idx_ci_ncci_target_delay on ncci_target_delay (accountkey)
+create nonclustered columnstore index idxncci_ncci_target_delay on
+ ncci_target_delay (accountkey, accountdescription, accounttype, accountcodealternatekey)
+ with (compression_delay= 30)
+
+
+
+--look at catalog view
+select object_name(object_id), name, type_desc, has_filter, compression_delay
+from sys.indexes where object_id = object_id ('ncci_target') or object_id=object_id('ncci_target_delay')
+
+--load data into NCCI
+-- takes around 2 minute
+insert into ncci_target select * from staging
+insert into ncci_target_delay select * from staging
+go 12
+
+
+-- look at rowgroups
+select object_name(object_id), *
+from sys.dm_db_column_store_row_group_physical_stats
+where object_id = object_id ('ncci_target') or object_id=object_id('ncci_target_delay')
+
+-- manual
+alter index idxncci_ncci_target on ncci_target reorganize with (COMPRESS_ALL_ROW_GROUPS = ON)
+
+-- Note, you can change compression delay just as a metadata operation
+alter index idxncci_ncci_target on ncci_target set (compression_delay=30)
+
+--++++++++++++++++++++++++++++++++++
+-- Memory Optimized Table
+--++++++++++++++++++++++++++
+
+drop table dbo.t_colstor_hk
+
+-- create a memopt table
+CREATE TABLE dbo.t_colstor_hk (
+ accountkey int not null,
+ accountdescription nvarchar (50),
+ accounttype nvarchar(50),
+ unitsold int,
+ CONSTRAINT [pk_t_colstor_hk] PRIMARY KEY NONCLUSTERED HASH (accountkey) WITH (BUCKET_COUNT = 10000000)--,
+-- index t_colstor_hk_cci clustered columnstore with (compression_delay=70)
+) WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_AND_DATA)
+go
+
+--you can add index after creating HK table (New in SQL 2016)
+alter table t_colstor_hk add index t_colstor_hk_cci clustered columnstore with (compression_delay=60)
+
+select object_name(object_id), name, type_desc, has_filter, compression_delay
+from sys.indexes where object_id = object_id ('t_colstor_hk')
diff --git a/samples/features/columnstore/NonclusteredColumnstore/ncci_demo.sql b/samples/features/columnstore/NonclusteredColumnstore/ncci_demo.sql
new file mode 100644
index 00000000..605ed86f
--- /dev/null
+++ b/samples/features/columnstore/NonclusteredColumnstore/ncci_demo.sql
@@ -0,0 +1,444 @@
+
+
+use master
+go
+
+drop database if exists ncci
+go
+
+
+
+CREATE DATABASE [ncci]
+ CONTAINMENT = NONE
+ ON PRIMARY
+( NAME = N'ncci_data', FILENAME = N'C:\data\ncci_Data.mdf' , SIZE = 102400KB , MAXSIZE = 5GB, FILEGROWTH = 1024000KB )
+ LOG ON
+( NAME = N'ncci_log', FILENAME = N'C:\data\ncci_Log.ldf ' , SIZE = 52400KB , MAXSIZE = 5GB , FILEGROWTH = 102400KB )
+GO
+
+use ncci
+go
+
+drop table if exists orders
+go
+
+-- create the table
+create table orders (
+ AccountKey int not null,
+ customername nvarchar (50),
+ OrderNumber bigint,
+ PurchasePrice decimal (9,2),
+ OrderStatus smallint not NULL,
+ OrderStatusDesc nvarchar (50))
+
+-- OrderStatusDesc
+-- 0 => 'Order Started'
+-- 1 => 'Order Closed'
+-- 2 => 'Order Paid'
+-- 3 => 'Order Fullfillment Wait'
+-- 4 => 'Order Shipped'
+-- 5 => 'Order Received'
+
+create clustered index orders_ci on orders(OrderStatus)
+
+set nocount on
+go
+
+set statistics time off
+go
+set statistics IO Off
+go
+
+-- insert into the main table load 3 million rows
+-- took 55 seconds (IO bound)
+declare @outerloop int = 0
+declare @i int = 0
+declare @purchaseprice decimal (9,2)
+declare @customername nvarchar (50)
+declare @accountkey int
+declare @orderstatus smallint
+declare @orderstatusdesc nvarchar(50)
+declare @ordernumber bigint
+while (@outerloop < 3000000)
+begin
+ Select @i = 0
+ begin tran
+ while (@i < 2000)
+ begin
+ set @ordernumber = @outerloop + @i
+ set @purchaseprice = rand() * 1000.0
+ set @accountkey = convert (int, RAND ()*1000)
+ set @orderstatus = 5
+
+ set @orderstatusdesc =
+ case @orderstatus
+ WHEN 0 THEN 'Order Started'
+ WHEN 1 THEN 'Order Closed'
+ WHEN 2 THEN 'Order Paid'
+ WHEN 3 THEN 'Order Fullfillment'
+ WHEN 4 THEN 'Order Shipped'
+ WHEN 5 THEN 'Order Received'
+ END
+
+ insert orders values (@accountkey,(convert(varchar(6), @accountkey) + 'firstname'),
+ @ordernumber, @purchaseprice, @orderstatus, @orderstatusdesc)
+ set @i += 1;
+ end
+ commit
+
+ set @outerloop = @outerloop + 2000
+ set @i = 0
+end
+go
+
+checkpoint
+go
+
+select count(*), OrderStatusDesc from orders group by OrderStatusDesc
+
+--create NCCI (note, not including PK column)
+-- took 14 secs
+CREATE NONCLUSTERED COLUMNSTORE INDEX orders_ncci ON orders (accountkey, customername, purchaseprice, orderstatus)
+
+-- look at the rowgroups
+select object_name(object_id), index_id, row_group_id, delta_store_hobt_id, state_desc, total_rows, trim_reason_desc, transition_to_compressed_state_desc
+from sys.dm_db_column_store_row_group_physical_stats
+where object_id = object_id('orders')
+
+
+-- set stats off
+set statistics time off
+go
+set statistics IO Off
+go
+
+--insert additional 200k rows
+declare @outerloop int = 3000000
+declare @i int = 0
+declare @purchaseprice decimal (9,2)
+declare @customername nvarchar (50)
+declare @accountkey int
+declare @orderstatus smallint
+declare @orderstatusdesc nvarchar(50)
+declare @ordernumber bigint
+while (@outerloop < 3200000)
+begin
+ Select @i = 0
+ begin tran
+ while (@i < 2000)
+ begin
+ set @ordernumber = @outerloop + @i
+ set @purchaseprice = rand() * 1000.0
+ set @accountkey = convert (int, RAND ()*1000)
+ set @orderstatus = convert (smallint, RAND()*5)
+ if (@orderstatus = 5) set @orderstatus = 4
+
+ set @orderstatusdesc =
+ case @orderstatus
+ WHEN 0 THEN 'Order Started'
+ WHEN 1 THEN 'Order Closed'
+ WHEN 2 THEN 'Order Paid'
+ WHEN 3 THEN 'Order Fullfillment'
+ WHEN 4 THEN 'Order Shipped'
+ WHEN 5 THEN 'Order Received'
+ END
+
+ insert orders values (@accountkey,(convert(varchar(6), @accountkey) + 'firstname'),
+ @ordernumber, @purchaseprice, @orderstatus, @orderstatusdesc)
+ set @i += 1;
+ end
+ commit
+
+ set @outerloop = @outerloop + 2000
+ set @i = 0
+end
+go
+
+
+
+-- START the demo here
+select count(*) from orders
+
+
+-- look at the rowgroups
+select object_name(object_id), index_id, row_group_id, delta_store_hobt_id, state_desc, total_rows, trim_reason_desc, transition_to_compressed_state_desc
+from sys.dm_db_column_store_row_group_physical_stats
+where object_id = object_id('orders')
+
+
+-- show the index columns
+select * from sys.index_columns where object_id = object_id('orders')
+
+-- analytics query performance
+set statistics time on
+go
+
+-- a complex query
+select top 5 customername, sum (PurchasePrice), Avg (PurchasePrice)
+from orders
+where purchaseprice > 90.0 and OrderStatus=5
+group by customername
+
+ -- a complex query without NCCI
+select top 5 customername, sum (PurchasePrice), Avg (PurchasePrice)
+from orders
+where purchaseprice > 90.0 and OrderStatus = 5
+group by customername
+option (IGNORE_NONCLUSTERED_COLUMNSTORE_INDEX)
+
+
+--+++++++++++++++++++++++++
+--CASE - Filtered Index
+-- Create Filtered NCCI
+-- ++++++++++++++++++++++++++
+drop table if exists orders_filtered
+go
+
+-- create the table
+create table orders_filtered (
+ AccountKey int not null,
+ customername nvarchar (50),
+ OrderNumber bigint,
+ PurchasePrice decimal (9,2),
+ OrderStatus smallint,
+ OrderStatusDesc nvarchar (50))
+
+-- OrderStatusDesc
+-- 0 => 'Order Started'
+-- 1 => 'Order Closed'
+-- 2 => 'Order Paid'
+-- 3 => 'Order Fullfillment Wait'
+-- 4 => 'Order Shipped'
+-- 5 => 'Order Received'
+
+create clustered index orders_ci on orders_filtered(OrderStatus)
+
+set nocount on
+go
+
+set statistics time off
+go
+set statistics IO Off
+go
+
+-- insert into the main table load 3 million rows
+declare @outerloop int = 0
+declare @i int = 0
+declare @purchaseprice decimal (9,2)
+declare @customername nvarchar (50)
+declare @accountkey int
+declare @orderstatus smallint
+declare @orderstatusdesc nvarchar(50)
+declare @ordernumber bigint
+while (@outerloop < 3000000)
+begin
+ Select @i = 0
+ begin tran
+ while (@i < 2000)
+ begin
+ set @ordernumber = @outerloop + @i
+ set @purchaseprice = rand() * 1000.0
+ set @accountkey = convert (int, RAND ()*1000000)
+ set @orderstatus = 5
+
+ set @orderstatusdesc =
+ case @orderstatus
+ WHEN 0 THEN 'Order Started'
+ WHEN 1 THEN 'Order Closed'
+ WHEN 2 THEN 'Order Paid'
+ WHEN 3 THEN 'Order Fullfillment'
+ WHEN 4 THEN 'Order Shipped'
+ WHEN 5 THEN 'Order Received'
+ END
+
+ insert orders_filtered values (@accountkey,(convert(varchar(6), @accountkey) + 'firstname'),
+ @ordernumber, @purchaseprice, @orderstatus, @orderstatusdesc)
+ set @i += 1;
+ end
+ commit
+
+ set @outerloop = @outerloop + 2000
+ set @i = 0
+end
+go
+
+
+CREATE NONCLUSTERED COLUMNSTORE INDEX orders_filtered_ncci
+ON orders_filtered (accountkey, customername, purchaseprice, orderstatus)
+where orderstatus = 5
+
+select * from sys.indexes where object_id=object_id('orders_filtered')
+
+-- look at the rowgroups
+select object_name(object_id), index_id, row_group_id, delta_store_hobt_id, state_desc, total_rows, trim_reason_desc, transition_to_compressed_state_desc
+from sys.dm_db_column_store_row_group_physical_stats
+where object_id = object_id('orders_filtered')
+
+
+select sum (total_rows)
+from sys.dm_db_column_store_row_group_physical_stats
+where object_id = object_id('orders_filtered')
+
+-- set stats off
+set statistics time off
+go
+set statistics IO Off
+go
+
+
+--insert additional 200k rows
+declare @outerloop int = 3000000
+declare @i int = 0
+declare @purchaseprice decimal (9,2)
+declare @customername nvarchar (50)
+declare @accountkey int
+declare @orderstatus smallint
+declare @orderstatusdesc nvarchar(50)
+declare @ordernumber bigint
+while (@outerloop < 3200000)
+begin
+ Select @i = 0
+ begin tran
+ while (@i < 2000)
+ begin
+ set @ordernumber = @outerloop + @i
+ set @purchaseprice = rand() * 1000.0
+ set @accountkey = convert (int, RAND ()*1000000)
+ set @orderstatus = convert (smallint, RAND()*5)
+ if (@orderstatus = 5) set @orderstatus = 4
+
+ set @orderstatusdesc =
+ case @orderstatus
+ WHEN 0 THEN 'Order Started'
+ WHEN 1 THEN 'Order Closed'
+ WHEN 2 THEN 'Order Paid'
+ WHEN 3 THEN 'Order Fullfillment'
+ WHEN 4 THEN 'Order Shipped'
+ WHEN 5 THEN 'Order Received'
+ END
+
+ insert orders_filtered values (@accountkey,(convert(varchar(6), @accountkey) + 'firstname'),
+ @ordernumber, @purchaseprice, @orderstatus, @orderstatusdesc)
+ set @i += 1;
+ end
+ commit
+
+ set @outerloop = @outerloop + 2000
+ set @i = 0
+end
+go
+
+
+
+-- START the demo here
+select count(*) As [Total Rows] from orders_filtered
+select count(*) AS [Closed Orders] from orders_filtered where OrderStatus = 5
+
+select sum (total_rows)
+from sys.dm_db_column_store_row_group_physical_stats
+where object_id = object_id('orders_filtered')
+
+-- look at the rowgroups
+select object_name(object_id), index_id, row_group_id, delta_store_hobt_id, state_desc, total_rows, trim_reason_desc, transition_to_compressed_state_desc
+from sys.dm_db_column_store_row_group_physical_stats
+where object_id = object_id('orders_filtered')
+
+
+
+-- analytics query performance
+set statistics time on
+go
+
+dbcc dropcleanbuffers
+
+--run query to show the query plan
+select max (PurchasePrice)
+from orders_filtered
+
+--run query to show the query plan
+-- when the index was not filtered
+select max (PurchasePrice)
+from orders
+
+-- a more complex query
+select top 5 customername, sum (PurchasePrice), Avg (PurchasePrice)
+from orders_filtered
+where purchaseprice > 90.0 and OrderStatus = 5
+group by customername
+
+
+
+-- a more complex query without NCCI
+ select top 5 customername, sum (PurchasePrice), Avg (PurchasePrice)
+from orders_filtered
+where purchaseprice > 100.0 and OrderStatus = 5
+group by customername
+option (IGNORE_NONCLUSTERED_COLUMNSTORE_INDEX)
+
+
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+-- CASE-3 - with no clustered index
+-- Create Filtered NCCI
+drop table if exists orders_filtered2
+go
+
+-- create the table
+create table orders_filtered2 (
+ accountkey int not null,
+ accountdescription nvarchar (50),
+ accounttype nvarchar(50),
+ unitsold int)
+
+
+set nocount on
+go
+
+set statistics time off
+go
+set statistics IO Off
+go
+
+-- insert into the main table load 10000 rows
+declare @outerloop int = 0
+declare @i int = 0
+while (@outerloop < 10000)
+begin
+ Select @i = 0
+
+ begin tran
+ while (@i < 2000)
+ begin
+ insert orders_filtered2 values (@i + @outerloop, 'test1', 'test2', @i)
+ set @i += 1;
+ end
+ commit
+
+ set @outerloop = @outerloop + 2000
+ set @i = 0
+end
+go
+
+
+--create NCCI
+CREATE NONCLUSTERED COLUMNSTORE INDEX orders_filtered2_NCCI
+ON orders_filtered2 (accountkey, accountdescription, unitsold) where accountkey > 0
+
+-- look at the row groups
+select *
+from sys.dm_db_column_store_row_group_physical_stats
+where object_id = object_id('orders_filtered2')
+
+select * from sys.index_columns where object_id = object_id('orders_filtered2')
+
+-- show that the 4th column is indeed included
+-- this is an internally generated column to uniquely identify the row
+sELECT segment_id, object_name(p.object_id), s.column_id, s.segment_id, s.min_data_id, s.max_data_id, s.encoding_type
+FROM sys.column_store_segments s, sys.partitions p
+where object_id = object_id('orders_filtered2') and
+p.hobt_id = s.hobt_id
+
+-- show the query plan with filtered index
+-- since there is no index to filter, it will do a table scan
+select avg (convert (bigint, unitsold))
+from orders_filtered2 with (index = orders_filtered2_ncci)
diff --git a/samples/features/columnstore/README.md b/samples/features/columnstore/README.md
new file mode 100644
index 00000000..eb1ccd27
--- /dev/null
+++ b/samples/features/columnstore/README.md
@@ -0,0 +1 @@
+# SQL Server columnstore
In-Memory Columnstore gives great performance to queries that scan large sets of rows (millions of rows typically), and also provides huge savings in storage space. Typical compression rates can be 90%. They are best used for analytics queries, and are default for many data warehouse schemas. When paired with Nonclustered indexes, they can support OLTP queries efficiently as well.
The performance gains come from:
* Data is physically organized by column rather than traditional pages which hold a number of complete rows.
* Data in s single row compresses very will since it is typically in the same data domain.
* Queries only need to read the data for those columns that the queries touch into memory. No data from other columns needs to be touched.
* Batch operations dramatically speed up aggregations on groups of rows at a time.
##Samples Included
* **Nonclustered Columnstore** This demo walks through adding a nonclustered columnstore to an OLTP table to enable fast analytics on an operational datastore.
* **In-Memory Columnstore** This demo walks through creating an in-memory columnstore index on an In-Memory OLTP table to provide extremely fast analytics on an extremely fast in-memory OLTP table.
\ No newline at end of file
diff --git a/samples/features/security/contoso-clinic/README.md b/samples/features/security/contoso-clinic/README.md
index 4cae984d..6ca46325 100644
--- a/samples/features/security/contoso-clinic/README.md
+++ b/samples/features/security/contoso-clinic/README.md
@@ -3,9 +3,9 @@
Sample application with database that showcases security features of SQL Server 2016.
## About this sample
-- **Applies to:** Azure SQL Database, Azure Web App Service, Azure Key Vault
+- **Applies to:** SQL Database 2016
- **Programming Language:** .NET C#, T-SQL
-- **Authors:** Jakub Szymaszek [jaszymas-MSFT], Daniel Rediske [daredis-msft]
+- **Authors:** Jakub Szymaszek [jaszymas-MSFT]
This project has adopted the [Microsoft Open Source Code of Conduct](http://microsoft.github.io/codeofconduct). For more information see the [Code of Conduct FAQ](http://microsoft.github.io/codeofconduct/faq.md) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
@@ -24,21 +24,22 @@ This project has adopted the [Microsoft Open Source Code of Conduct](http://micr
##Prerequisites
1. Visual Studio 2015 (or newer)
-2. [SQL Server 2016](https://www.microsoft.com/en-us/evalcenter/evaluate-sql-server-2016) OR an Azure SQL Database (V12) [portal link](https://portal.azure.com)
-3. [SQL Server Management Studio](https://msdn.microsoft.com/en-us/library/mt238290.aspx.)
+2. [SQL Server 2016](https://www.microsoft.com/en-us/evalcenter/evaluate-sql-server-2016)
+3. [SQL Server Management Studio](https://msdn.microsoft.com/en-us/library/mt238290.aspx)
##Setup
### Set up the Demo Database
1. Clone/Download the repository
-2. While connected to your database (master) via SSMS, execute [Create-Application-Login.sql](tsql/Create-Application-Login.sql) link.
- + You should change the default password in the script before running it.
-3. Import the *Clinic* database
+2. Import the *Clinic* database
+ Open SSMS and connect to your SQL Server 2016 instance (or Azure SQL Database instance)
+ In SSMS, right-click on *Databases* in Object Explorer and select *Import Data-tier Application...*.
+ Locate your copy of the bacpac file, located in the */setup* folder.

+ Complete the steps of the wizard.
+ NOTE: the Clinic database contains the ContosoClinicApplication database user, based on the ContosoClinicApplication login, which you provisioned above. The user is assigned a few roles and is granted permissions which are required to complete the demos in this package.
+3. While connected to your database (master) via SSMS, execute [setup/Create-Application-Login.sql](setup/Create-Application-Login.sql) link.
+ + The script will prompt you for your desired password for the `ContosoClinicApplicaation` user.
+ + This script also modifies the permissions of the `ContosoClinicApplication` user
### Modify and Set up the Sample Application Project
1. Start Visual Studio and open the Contoso Application solution file- located in /src.
@@ -47,8 +48,13 @@ This project has adopted the [Microsoft Open Source Code of Conduct](http://micr
+ Using Solution Explorer, locate and open the web.config file under the ContosoClinic project.
+ Look for the line that looks like this:
```csharp
-
+
+
+
+
```
+ Update the value of the *Data Source* key word in the database connection string to denote your server (either your local SQL Server instance of your logical server in Azure SQL Database)
+ Make sure the *password* for your application users is correct (matches the password that you configured earlier)
diff --git a/samples/features/security/contoso-clinic/setup/Clinic.bacpac b/samples/features/security/contoso-clinic/setup/Clinic.bacpac
index eb0ad16a..747ccd68 100644
Binary files a/samples/features/security/contoso-clinic/setup/Clinic.bacpac and b/samples/features/security/contoso-clinic/setup/Clinic.bacpac differ
diff --git a/samples/features/security/contoso-clinic/setup/Create-Application-Login.sql b/samples/features/security/contoso-clinic/setup/Create-Application-Login.sql
index b41468b6..ceba8b96 100644
--- a/samples/features/security/contoso-clinic/setup/Create-Application-Login.sql
+++ b/samples/features/security/contoso-clinic/setup/Create-Application-Login.sql
@@ -1,3 +1,9 @@
-- Create a non-sysadmin account for the application to use
-CREATE LOGIN ContosoClinicApplication WITH PASSWORD = '{Some Strong Password}'
+CREATE LOGIN [ContosoClinicApplication] WITH PASSWORD =
+CREATE USER [ContosoClinicApplication] FOR LOGIN [ContosoClinicApplication]
+EXEC sp_addrolemember N'db_datareader', N'ContosoClinicApplication'
+EXEC sp_addrolemember N'db_datawriter', N'ContosoClinicApplication'
+GRANT VIEW ANY COLUMN MASTER KEY DEFINITION TO [ContosoClinicApplication]
+GRANT VIEW ANY COLUMN ENCRYPTION KEY TO [ContosoClinicApplication]
+