From 216830ffba0ba4c6f1f50cb3733904548c770515 Mon Sep 17 00:00:00 2001 From: ShiyangQiu Date: Thu, 8 Sep 2016 12:04:14 +0800 Subject: [PATCH] Change of In-Memory Demo 1. t-sql-scripts\enable-in-memory-oltp.sql is appled to sql 2016 or higher 2. modify the sql script name in readme of ticket-reservations 3. add the table type control for Demo_Reset stored proc. --- .../in-memory/t-sql-scripts/enable-in-memory-oltp.sql | 2 +- samples/features/in-memory/ticket-reservations/README.md | 4 ++-- .../dbo/Stored Procedures/Demo_Reset.sql | 9 ++++++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/samples/features/in-memory/t-sql-scripts/enable-in-memory-oltp.sql b/samples/features/in-memory/t-sql-scripts/enable-in-memory-oltp.sql index 7a02bc4c..ab527b1e 100644 --- a/samples/features/in-memory/t-sql-scripts/enable-in-memory-oltp.sql +++ b/samples/features/in-memory/t-sql-scripts/enable-in-memory-oltp.sql @@ -10,7 +10,7 @@ -- need to use the WITH (SNAPSHOT) hint for ad hoc queries accessing memory-optimized -- tables. -- --- Applies To: SQL Server 2014 (or higher); Azure SQL Database +-- Applies To: SQL Server 2016 (or higher); Azure SQL Database -- Author: Jos de Bruijn (Microsoft) -- Last Updated: 2016-05-02 diff --git a/samples/features/in-memory/ticket-reservations/README.md b/samples/features/in-memory/ticket-reservations/README.md index 6e167823..0e0a1e63 100644 --- a/samples/features/in-memory/ticket-reservations/README.md +++ b/samples/features/in-memory/ticket-reservations/README.md @@ -41,8 +41,8 @@ This Windows Forms sample application built on .NET Framework 4.6 demonstrates 8. Start the workload with the **Start** button, and run for a while to show perf profile. Then press stop to stop the workload. You can tweak aspects of the workload (e.g., rows per transaction) through the configuration form accessed using the "Options" menue. 9. In the database project, - - Change TicketReservations.sql to a memory-optimized table (instructions commented in the file itself) - - Change InsertTicketReservations.sql to natively compiled (instructions in the same file) + - Change TicketReservationDetail.sql to a memory-optimized table (instructions commented in the file itself) + - Change InsertReservationDetails.sql to natively compiled (instructions in the same file) 10. Publish the database project to the same database – the tool will take care of making the necessary changes. Note that, as part of publication, the data is copied from the old disk-based table to the new memory-optimized table, so the longer you run the initial workload, the longer this publication takes. To speed up the process you can run `TRUNCATE TABLE dbo.TicketReservationDetail` in the database. diff --git a/samples/features/in-memory/ticket-reservations/TicketReservations/dbo/Stored Procedures/Demo_Reset.sql b/samples/features/in-memory/ticket-reservations/TicketReservations/dbo/Stored Procedures/Demo_Reset.sql index 022c1e07..9e66de4e 100644 --- a/samples/features/in-memory/ticket-reservations/TicketReservations/dbo/Stored Procedures/Demo_Reset.sql +++ b/samples/features/in-memory/ticket-reservations/TicketReservations/dbo/Stored Procedures/Demo_Reset.sql @@ -1,4 +1,11 @@  create proc Demo_Reset as -TRUNCATE TABLE dbo.TicketReservationDetail; +DECLARE @isMemoryTable BIT + +SELECT @isMemoryTable = is_memory_optimized FROM sys.tables +WHERE [name] = 'TicketReservationDetail' + +IF(@isMemoryTable= 1) DELETE dbo.TicketReservationDetail +ELSE TRUNCATE TABLE dbo.TicketReservationDetail; +