During these last days I've been working with some service requests related with DataSync based on some limitations of this feature has.
Before using DataSync I would like to share with you this post that includes some checks to be performed before using Datasync.
Following you could find some of these checks to be done:
In order to validate these checks, I created the following TSQL that perform these validations, all feedback and improvement are welcome:
Also, remember, that we have the following PowerShell script that you could run once DataSync has been created to review if everything is correct: https://github.com/microsoft/AzureSQLDataSyncHealthChecker
Enjoy!
-------------------------------------------------------
-- Script to validate my database to use DataSync
--------------------------------------------------------
IF (SELECT ISNULL(COUNT(*),0) FROM sys.tables where sys.tables.is_ms_shipped=0)>=500
Print 'Check #1: Fail - You have more than 500 tables'
ELSE
Print 'Check #1: Success - You do not have the maximum tables to Sync'
-----------
-- Review if you have permissions to DataSync Schema
-----------
DECLARE @tablename sysname, @object_id bigint, @nTemporal int
DECLARE TablesCursor CURSOR FOR SELECT Name, OBJECT_ID FROM sys.tables where sys.tables.is_ms_shipped=0 order by Name;
OPEN TablesCursor
FETCH NEXT FROM TablesCursor INTO @tablename, @object_id
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT ' '
PRINT 'Control #2: Table: ' + @tablename + '-- ' + CONVERT(varchar(200),@object_id)
DECLARE PermissionsCursor CURSOR FOR SELECT TOP 1 grantee_principal_id
FROM sys.database_permissions p
WHERE major_id = @object_id and grantee_principal_id = USER_ID() AND permission_name='CONTROL'
OPEN PermissionsCursor
FETCH NEXT FROM PermissionsCursor INTO @nTemporal
IF @@FETCH_STATUS = 0
PRINT ' -----> Has enough permissions'
ELSE
PRINT ' -----> Fail - Has not enough permissions'
CLOSE PermissionsCursor
DEALLOCATE PermissionsCursor
IF LEN(@TableName)>50 PRINT ' -----> Fail - The name of the table reached the maximum length'
DECLARE ColsCursor CURSOR FOR SELECT TOP 1 object_id
FROM sys.columns
WHERE object_id = @object_id AND len(name)>50
OPEN ColsCursor
FETCH NEXT FROM ColsCursor INTO @nTemporal
IF @@FETCH_STATUS = 0
PRINT ' -----> Fail - The length of some column name of this table is reached the maximum allowed'
ELSE
PRINT ' -----> The length of some column name of this table is not reached the maximum allowed'
CLOSE ColsCursor
DEALLOCATE ColsCursor
FETCH NEXT FROM TablesCursor INTO @tablename, @object_id
END
CLOSE TablesCursor;
DEALLOCATE TablesCursor
---
-- Check if DataSync schema is created and has control permissions
----
IF (SELECT ISNULL(COUNT(*),0) FROM sys.schemas where name='DataSync')=1
Print 'Check #3: You have the schema DataSync created'
ELSE
Print 'Check #3: Fail - You do not have the schema DataSync created'
-----------
-- Review if you have permissions to DataSync Schema
-----------
IF HAS_PERMS_BY_NAME('DATASYNC', 'SCHEMA', 'CONTROL')=1
Print 'Check #4: You have control permission in DataSync schema'
ELSE
Print 'Check #4: You do not have control permission in DataSync Schema'
-----------
-- Review if you have permissions to DataSync Schema
-----------
IF (SELECT snapshot_isolation_state FROM sys.databases where name=db_name()) = 1 AND
(SELECT is_read_committed_snapshot_on FROM sys.databases where name=db_name()) = 1
Print 'Check #5: You have snapshot isolation level'
ELSE
Print 'Check #5: You dont have snapshot isolation level'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.