?
Solved

MS SQL - Synchronize 2 tables definition

Posted on 2015-02-09
4
Medium Priority
?
73 Views
Last Modified: 2015-02-13
Hi,
Is there any stored procedure that can help to synchronize 2 tables definitions?
Let say I have table A and I want fields in table B (not existing in table A) to be added to table A.
And if any datatype change is picked up on common fields, adjust fields in table A
Only at table definition.
0
Comment
Question by:Omer-Pitou
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 70

Accepted Solution

by:
Scott Pletcher earned 750 total points
ID: 40599562
No, there's no system procedure that comes with SQL Server that would do that for you.  It would have to be custom code.
0
 
LVL 49

Expert Comment

by:PortletPaul
ID: 40600029
and good luck with automating "And if any datatype change is picked up on common fields, adjust fields in table A"

How broad is that requirement.

e.g. From varchar to datetime? From varchar(250) to varchar(4)? (both are likely to have exceptions in the data)
0
 

Author Comment

by:Omer-Pitou
ID: 40600043
It can be done. In this case you can force the column to be truncated. It is just a lot of coding.
0
 
LVL 52

Assisted Solution

by:Vitor Montalvão
Vitor Montalvão earned 750 total points
ID: 40600943
It can be done. In this case you can force the column to be truncated. It is just a lot of coding.
Yes it can be done and maybe with less coding that you think. Check for DDL triggers. Here's a starting point for you:
CREATE TRIGGER TableChanges
ON DATABASE 
FOR ALTER_TABLE 
AS 
   (...)

Open in new window

0

Featured Post

What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question