recreate system tables

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Vassago

    recreate system tables

    Hi!
    I need to recreate the system tables (sysobjects, syscolumns,
    sysindexes, sysforeignkeys, sysconstraints, sysreferences, sysindexkeys
    at least) in another SQL server.
    You may say "Thats easy! Backup and restore the database!" and I would
    answer "I can't, the database size is above 50GB and I just can't do it
    every time I need to recreate the info".
    So, ¿Do you know any simple way to do these?

    I don't need the data on the user tables and I'll log-in always as dbo
    (using trusted connection), perhaps that helps.
    Perhaps the simplest way is to do a bcp to backup and restore the data
    but.... you never know what would happen. This is why I write ask you
    guy, probably you know much more than me.

    Thanks in advance

  • Vassago

    #2
    Re: recreate system tables

    Another thing: I need to recreate them because the important thing is
    the relation name-id on each table.
    I have an application that has the Id of the objects in the sysobjects
    table and I need to know it's name.

    Comment

    • David Portas

      #3
      Re: recreate system tables

      Use Enterprise Manager to generate the creation script for the database.
      Right-click the DB, select All Tasks > Generate Scripts.

      --
      David Portas
      SQL Server MVP
      --


      Comment

      • David Portas

        #4
        Re: recreate system tables

        > I have an application that has the Id of the objects in the sysobjects[color=blue]
        > table and I need to know it's name.[/color]

        You mean the object IDs are referenced in the application?! I'm sorry, but
        that just seems unbelievably stupid! I would tell the customer to dump that
        application ASAP.

        I think the best you can do is try to run the creation scripts in the right
        order in an attempt to generate the correct IDs. You'll have to query the
        system tables for the current state and then try to reproduce it in a
        script. Use that information to fix the application code if you are able.

        --
        David Portas
        SQL Server MVP
        --


        Comment

        • Vassago

          #5
          Re: recreate system tables

          It's long to tell why I need the ids but I can tell you that is a third
          party tool and it works that way, I can't change it. I also can tell
          tou that I hate it because the way it works but I can't do anything
          about it.
          What you suggest is nearly imposible, I can't recreate the ids for
          every primary key and every index.
          i don't care if the database is messy, I just need the ids.
          Is there any way to backup just the schema withou the data?

          Comment

          • David Portas

            #6
            Re: recreate system tables

            You could restore the entire database then delete all the data, shrink it
            and then back it up again. Once you've done that backup you'd have it for
            future reference. Maybe someone else can come up with something better but I
            can't think of another way to preserve the IDs.

            --
            David Portas
            SQL Server MVP
            --

            "Vassago" <iciruzzi@gmail .com> wrote in message
            news:1122572272 .797029.108370@ o13g2000cwo.goo glegroups.com.. .[color=blue]
            > It's long to tell why I need the ids but I can tell you that is a third
            > party tool and it works that way, I can't change it. I also can tell
            > tou that I hate it because the way it works but I can't do anything
            > about it.
            > What you suggest is nearly imposible, I can't recreate the ids for
            > every primary key and every index.
            > i don't care if the database is messy, I just need the ids.
            > Is there any way to backup just the schema withou the data?
            >[/color]


            Comment

            • Vassago

              #7
              Re: recreate system tables

              We are talking of a database of at least 100gb... imagine the time I
              need to backup, restore, delete data and shrink it.
              Thanks anyway.

              Comment

              • David Portas

                #8
                Re: recreate system tables

                You mean you don't back it up anyway? Why is time a factor for this? How
                often do you expect to have to do it?

                --
                David Portas
                SQL Server MVP
                --


                "Vassago" <iciruzzi@gmail .com> wrote in message
                news:1122574013 .104947.297100@ o13g2000cwo.goo glegroups.com.. .[color=blue]
                > We are talking of a database of at least 100gb... imagine the time I
                > need to backup, restore, delete data and shrink it.
                > Thanks anyway.
                >[/color]


                Comment

                • Vassago

                  #9
                  Re: recreate system tables

                  Yes we do back it up, but to tape and the other SQL (the one i'm using)
                  does not have tape device.
                  As the app I'm using need the info I need to keep my db as updated as
                  possible.

                  Comment

                  • Erland Sommarskog

                    #10
                    Re: recreate system tables

                    Vassago (iciruzzi@gmail .com) writes:[color=blue]
                    > We are talking of a database of at least 100gb... imagine the time I
                    > need to backup, restore, delete data and shrink it.[/color]

                    I can tell you that this time is only a mere fraction of the time you
                    could waste on your other dead idea. And, I don't really see why you
                    would need to this multiple times. Do it once, and then create an
                    empty template database to work from.

                    The total time for this operation is less than 24 hours.


                    --
                    Erland Sommarskog, SQL Server MVP, esquel@sommarsk og.se

                    Books Online for SQL Server SP3 at
                    Get the flexibility you need to use integrated solutions, apps, and innovations in technology with your data, wherever it lives—in the cloud, on-premises, or at the edge.

                    Comment

                    Working...