Skip to content

Instantly share code, notes, and snippets.

@lionofdezert
lionofdezert / SYNC_ColumnsDefaultValues.sql
Created November 29, 2013 18:40
Stored Procedure, to create missing columns default values at target database by comparing both source and target databases.
--DROP IF ALREADY EXISTS
IF EXISTS ( SELECT 1
FROM SYS.procedures
WHERE NAME = 'SYNC_ColumnsDefaultValues' )
DROP PROC SYNC_ColumnsDefaultValues
GO
--CREATE PROCEDURE
SET ANSI_NULLS ON
GO
@lionofdezert
lionofdezert / SYNC_CreateMissingColumns.sql
Created November 29, 2013 18:46
Stored Procedure, to create missing columns at target database by comparing both source and target databases.
--DROP IF ALREADY CREATED
IF EXISTS (SELECT 1 FROM sys.objects WHERE type = 'P' AND name = 'SYNC_CreateMissingColumns')
DROP PROC [dbo].[SYNC_CreateMissingColumns]
GO
--CREATE PROCEDURE
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*
@lionofdezert
lionofdezert / SYNC_CreatePrimaryKeys.sql
Created November 29, 2013 18:48
Stored Procedure, to create missing primary keys at target database by comparing both source and target databases.
--DROP IF ALREADY CREATED
IF EXISTS ( SELECT 1
FROM SYS.procedures
WHERE NAME = 'SYNC_CreatePrimaryKeys' )
DROP PROC SYNC_CreatePrimaryKeys
GO
--CREATE PROCEDURE
SET ANSI_NULLS ON
GO
@lionofdezert
lionofdezert / SYNC_Indexes.sql
Created November 29, 2013 18:50
Stored Procedure, to create missing indexes on tables values at target database by comparing both source and target databases.
--DROP IF ALREADY EXISTS
IF EXISTS ( SELECT 1
FROM SYS.PROCEDURES
WHERE NAME = 'SYNC_Indexes' )
DROP PROCEDURE SYNC_Indexes
GO
--CREATE PROCEDURE
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON