Solved

MS SQL - Synchronize 2 tables definition

Posted on 2015-02-09
4
66 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 69

Accepted Solution

by:
Scott Pletcher earned 250 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 51

Assisted Solution

by:Vitor Montalvão
Vitor Montalvão earned 250 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
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.

628 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