472,348 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,348 software developers and data experts.

No triggers, constraints

I have several sql server databases that were recently moved to a new
server. In the process of migrating the databases, any triggers and
constraints attached to tables were removed on accident. I need to add
these objects back into the databases, however I'm worried that I will
have problems with referential integrity since there is a chance
someone may have deleted or updated a record that should have cascaded
changes to other tables but did not since the triggers and constraints
were missing. Is there an easy way to check for problems of this
nature in the databases?

Also - I am planning on generating a script from the database on the
old server that scripts the triggers and constraints, and then use
Query Analyser to run this script against the database on the new
server. Is this the best way to add these objects back into databases
that are already populated with data and running on a live server?

In in a pretty bad position, but at least these are databases that are
not accessed too frequently, so I'm hoping any referential integrity
problems will be minor.
Any help or advice would be greatly appreciated.

Jul 20 '05 #1
1 1936

<ja**********@hotmail.com> wrote in message
news:10**********************@c13g2000cwb.googlegr oups.com...
I have several sql server databases that were recently moved to a new
server. In the process of migrating the databases, any triggers and
constraints attached to tables were removed on accident. I need to add
these objects back into the databases, however I'm worried that I will
have problems with referential integrity since there is a chance
someone may have deleted or updated a record that should have cascaded
changes to other tables but did not since the triggers and constraints
were missing. Is there an easy way to check for problems of this
nature in the databases?
Not really, since in order to check this you would need to know the
primary/foreign keys that should be there anyway. So you might as well just
add them back again, and see if you get any errors. Triggers are a bit more
of a problem, but if you're only using them for RI, then hopefully adding
the foreign keys will pick up any problems. If you have more complex
business rules in triggers, then there are no real shortcuts except to work
through your logic and see if any data is incorrect - hopefully you don't
have too many...
Also - I am planning on generating a script from the database on the
old server that scripts the triggers and constraints, and then use
Query Analyser to run this script against the database on the new
server. Is this the best way to add these objects back into databases
that are already populated with data and running on a live server?
That's fine. If the script is large, make sure you run it in chunks to avoid
getting too many errors back in one go. And of course try it out on a test
copy of the database first.

In in a pretty bad position, but at least these are databases that are
not accessed too frequently, so I'm hoping any referential integrity
problems will be minor.
Any help or advice would be greatly appreciated.


For the future, you might want to review how you move databases to new
servers (backup/restore is usually an easy option, and you can't lose
anything that way), and perhaps look at some schema comparison tools, which
can help you find and fix schema issues. This one is quite good, but there
are plenty of others:

http://red-gate.com/SQL_Compare.htm

Simon
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: jason_s_ford | last post by:
I have several sql server databases that were recently moved to a new server. In the process of migrating the databases, any triggers and...
4
by: Mark Flippin | last post by:
I'm just starting to use triggers in my databases and find the support in Enterpise Manager lacking. Using Enterprise Manager and Query Analyzer...
4
by: Dan | last post by:
I am loading data from table A into table B. Certain columns in B have check constraints. I'd like for any rows from A, which violate constraints,...
1
by: Christoph Graf | last post by:
Hi everybody! As far as I have seen you can inherit from a table and get its columns. Is there a possibility to also inherit a tables triggers?...
2
by: Janning Vygen | last post by:
hi PGurus, i searched the archives and read the docs, because this problem shouldn't be new. But i really don't know what to search for. i am...
1
by: SVGK, Raju | last post by:
Hi, I have a table where in lot of triggers were included in that as shown below. How to view/access triggers and procedures from postgresql. ...
5
by: Mike Mascari | last post by:
I'd like to ensure that the creation of a department also implies the creation of two to eight projects; no more, no less: CREATE TABLE...
0
debasisdas
by: debasisdas | last post by:
This thread contains some useful tips/sample codes regarding TRIGGERS in oracle, that the forum members may find useful. TRIGGERS:...
4
by: --CELKO-- | last post by:
I need to convert a bunch of DB2 triggers to Oracle. Is there any kind of tools for this?
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.