To enable Stretch DB for a table, you can also choose between the wizard and Transact-SQL. You can migrate an entire table or just part of a table. If your cold data is stored in a separated table, you can migrate the entire table; otherwise you must specify a filter function to define which rows should be migrated. To enable the Stretch DB feature for a table, you must be a member of the db_owner role. In this section, you will create a new table in the Mila database, populate it with a few rows, and enable it for stretching. Use this code to create and populate the table:
USE Mila; CREATE TABLE dbo.T1( id INT NOT NULL, c1 VARCHAR(20) NOT NULL, c2 DATETIME NOT NULL, CONSTRAINT PK_T1 PRIMARY KEY CLUSTERED (id) );
GO INSERT INTO dbo.T1 (id, c1, c2) VALUES
(1, 'Benfica Lisbon','20180115'),
(2, 'Manchester United','20180202'),
(3, 'Rapid Vienna','20180128'),
(4, 'Juventus Torino','20180225'),
(5, 'Red Star Belgrade','20180225');
In the next sections, you will enable and use the Stretch DB feature for the T1 table. Assume that you want to move all rows from this table with a value in the c2 column that is older than 1st February 2018 to the cloud.