Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Replicate a table- with the constraints and data

Author  Topic 

raghav_sai2002
Starting Member

18 Posts

Posted - 2009-10-30 : 05:24:32
Hi,

i am just curious about something, i thought may be the experts can clarify on this one.

recently we got a new test environment, but as the data was really heavy in production, the DBA decided to get data only for one customer account but not for all the accounts.

i dont know how he did the replication, but when we tried to execute some features which were working even in production, they were causing exceptions. after some research i found that the root cause was that the table was missing constraints like defaults, identity and so on.
when we asked him he said he did it intentionally which i dont beleive.

my question is
1. if he did it intentionally what would be the possible reason.

2. and what i think he would have done is something like this
he might have created the tables along with the data using the command
USING Server1.DB1
Select * INTO DB1.tbl1 FROM server2.DB1.tbl1

which would have created data and the schema, but not the constraints.

so what i want to know is.. is there a possible way, in which i can write as script to get all the table names from the sysobjects in server1, and copy it along with constraints into server2.

as i had to invest lot of time on testing out which areas are missing the constraints.

thank you very much.





russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-10-30 : 09:13:47
he may have done it intentionally, but he still did it wrong. why not have him do it right?
Go to Top of Page

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2009-10-30 : 14:08:54
if he did it intentionally he might have wanted to see your troubleshooting skills or he was not thinking it through all the way, he might not know that the select statement you suspect him of running does not bring in constraint, he might be stressed out, he might the owner's son etc etc. there are many lovely tools out there that can help you compare two seperate databases and tell you what is missing in the destination database, like SQL Compare from Red Gate (am I allowed to say this)

you need to sit down and have a heart to heart talk with your dba. same one that does not want #temp tables I guess.

<><><><><><><><><><><><><><><><><><><><><><><><><>
If you don't have the passion to help people, you have no passion
Go to Top of Page
   

- Advertisement -