Script Database relations

  • well

    I want to script only database relations without table script except the script must have all 'drop relation' statements,then it must contain 'create relation' statements,is there any system or catalog view which I can use?

  • a.ghasemi (4/10/2011)


    is there any system or catalog view which I can use?

    Yes. It's in Books Online.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • what type of answer is it?

    please read my question again

  • a.ghasemi (4/10/2011)


    well

    I want to script only database relations without table script except the script must have all 'drop relation' statements,then it must contain 'create relation' statements,[font="Arial Black"]is there any system or catalog view which I can use?[/font]

    a.ghasemi (4/11/2011)


    what type of answer is it?

    please read my question again

    It's the one that answers your question which I've bolded in your original question. 😉

    Lookup "FOREIGN KEY constraints, disabling" in Books Online. It tells you where the proper catalog view to use, etc. It should take you just a couple of minutes to work out a script on your own. I'm trying to help you help yourself. :w00t:

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • thanks for replying

    but when I say that is there any system or catalog view,I mean if any type of view exists which holds complete script of the relations not only the name of the relations,for example syscomments view has a column named text which holds the actual script of stored procedures and triggers but I didn't find anything for relations.

    if you mean the generate script wizard of sql server,it only produces the script of relations with create table script,but I want only all of the relations together, first drop statements of relations then create statement of relations and nothing more

  • Let me translate.

    Jeff wants you to learn to do it yourself and he gave you the exact reference you need.

    Plan B would be to use google for a fully made script. I don't have 1 I can send you.

  • Ok,I got this,but you can be sure that I have searched in internet and MSDN but I didn't find anything

  • I'm not sure what terms you might have searched for, so try a google search for

    sql server script database relations

    or

    sql server script foreign keys

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • 2nd link in google.

    http://msdn.microsoft.com/en-us/library/ms177463.aspx

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply