Tuesday, September 10, 2013

Demo: Create a Memory Optimized Table

Note: This is part of a series on SQL Server 2014 In Memory. Start here

--
-- Create memory-optimized table
--
CREATE TABLE Destination_Memory
(
--See the section on bucket_count for more details on setting the bucket count.
col1 INT NOT NULL PRIMARY KEY NONCLUSTERED HASH WITH (BUCKET_COUNT = 100000),
col2 INT NOT NULL,
col3 INT NOT NULL
) WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_AND_DATA)
GO

--
-- Insert into memory table using T-SQL
--
SET NOCOUNT ON;
delete from Destination_Memory;
declare @i int;
select @i = 1;
while @i < 20000
  begin
insert into Destination_Memory values(@i, @i, @i);
select @i = @i + 1;
  end;
select count(*) from Destination_Memory;

No comments:

Post a Comment