It’s been a week I was playing around this new feature. Now I’m going to drop\disable this feature so save some $ in my Azure subscription 🙂
Disabling this is a tricky one as we knew we moved our data from in house server to the cloud. Now when you disable it the data will be partially in cloud and the rest will be in our server. So first step is to get the data from the cloud to our inhouse server. Time taken depends on the volume of data and the network speed between inhouse and cloud server.
There are lot of methods but I prefer my method because of less down time or you can switch over in no time.
- Pause database stretching
[sql]ALTER TABLE TRIP SET ( REMOTE_DATA_ARCHIVE ( MIGRATION_STATE = PAUSED ) ) ;[/sql]
- Bring back data to a temp table
[sql]SELECT * INTO TRIP_temp FROM TRIP[/sql]
- Move the data from temp table to the actual table
[sql]SET IDENTITY_INSERT TRIP ON
INSERT INTO TRIP
SELECT * FROM TRIP_temp
DROP TABLE TRIP_temp[/sql]
- Ensure you got all the data into the actual table before you disable it or else drop the temp table some point later. Now disable streching at table level. When you do the same step via GUI it will warn you that the table and database in Azure wont be dropped and it will be there so we have to manually clear it. Just right click on the table, go to Stretch and then Disable
- However when you do it via below TSQL query it wont warn you anything. It will be good if Microsoft add a small piece of information.
[sql]ALTER TABLE TRIP SET ( REMOTE_DATA_ARCHIVE = OFF ( MIGRATION_STATE = PAUSED ) )[/sql]
- Now let’s disable at streching at database level
[sql]ALTER DATABASE SampleDB
SET REMOTE_DATA_ARCHIVE = OFF[/sql]
- Now let’s disable at server level. If you enabled stretch for any other database then dont disable it server level.
[sql]IF( SELECT value_in_use
WHERE name = ‘remote data archive’ ) = 1
EXEC sp_configure ‘remote data archive’, 0;
In Azure (Cloud)
- Connect to the Azure server
- Run the below command to drop the database created for streching. It’s easy to identify the db name, it will be unique.
[sql]DROP DATABASE [RDASampleDB6D511ED3-2041-45F3-8AEC-1CF9D858CC89][/sql]