Solved

MS SQL - Synchronize 2 tables definition

Posted on 2015-02-09
4
53 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
4 Comments
 
LVL 69

Accepted Solution

by:
ScottPletcher 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 48

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 45

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now