Results 1 to 9 of 9
  1. #1
    Join Date
    Mar 2008
    Posts
    9

    Unanswered: Database backup (URGENT)

    Hi

    I have a db backup requirement. As shown in the attached image current system is as follows:

    1. There are three source databases such as DB001, DB002 and DB003. Each DB having one table as dbo.EMP and same table schema.
    2. Emp table consists of EmpID (PK) and EmpName.
    3. One backup database i.e, DBbackup


    I need as follows:

    1. Looping through all DB: "SELECT NAME FROM sys.sysdatabases WHERE NAME LIKE ''DB00%''"
    2. Check if table dbo.EMP exist in each DB.
    3. If exist then check table "001" exist in DB "DBbackup". >> "SELECT OBJECT_ID('DBbackup.dbo.001','U') AS Check " . This query will return NULL if table "001" not exist.
    4. If not exist then create a table by taking part of DB name like "001" with same schema in "DBbackup" database.
    5. Select into "001", from dbo.Emp before matching row count to avoid duplicate records.

    Can you give idea how to achieve it.

    Data export of each table is very time consuming. There are more than 150 DBs with huge data. Is there any alternative wizard or inbuilt script is there in SQL server 2005.

    Can it be achieve by stored procedure.

    Can we put a time stamp in SP to check the processing time for each DB.

    Expecting for your solution. Its very urgent.

    Thanks

    Sharma
    Attached Thumbnails Attached Thumbnails Databases.jpg  

  2. #2
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    my freshman year I did not do a lick of schoolwork until Thanksgiving either. Of course I was the only 18 year old in a suit of 21 year old transfer students and the rest of the hall was freshman girls. I would write a screenplay but much of it is fuzzy.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  3. #3
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,799
    Provided Answers: 11
    This is your backup strategy?? Copy a table to another database? What about any other tables you might have? Why backup only the emp table?? Someone should lose their job for suggesting something so prone to failure.

  4. #4
    Join Date
    Mar 2008
    Posts
    9
    Quote Originally Posted by Thrasymachus
    my freshman year I did not do a lick of schoolwork until Thanksgiving either. Of course I was the only 18 year old in a suit of 21 year old transfer students and the rest of the hall was freshman girls. I would write a screenplay but much of it is fuzzy.
    Im not getting you. Are you not clear about my post?

  5. #5
    Join Date
    Mar 2008
    Posts
    9
    Quote Originally Posted by MCrowley
    This is your backup strategy?? Copy a table to another database? What about any other tables you might have? Why backup only the emp table?? Someone should lose their job for suggesting something so prone to failure.
    This is like a backup strategy. Migrating to new system. Before each application having individual DB but actually having only one table i.e, in different name. For example i have given EMP table. Now we want to move data to individual table in a single DB from different DBs.

    DTS allowing only one DB at a time and there are more than 150 tables with millions of records. So this process will take long time.

    Can you please write me a script for this.

    Thanks

  6. #6
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    First, we are here to give advice and trouble-shoot. We don't do your coding for you for free.
    Second, one of us might be willing to invest the time in coding this for you if it had actual value, but it doesn't. There are much better ways to achieve what you want, such as SSIS packages, BCP, replication, mirroring, etc.
    I, for one, would not spend an hour coding something which is a bad practice to begin with.
    So....please explain your business requirements, clearly, and we can help you come up with the best solution, be it code or something else.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  7. #7
    Join Date
    Dec 2007
    Location
    London, UK
    Posts
    741
    I agree with blindman. It seems that you have an administrative problem (and possibly a design problem also) for which you have already concluded a script is the best solution, so what you've posted here is a request for a script.

    Also, it's inaccurate to say that DTS "allows" only one DB at a time (whatever that is supposed to mean).

  8. #8
    Join Date
    Jun 2004
    Location
    Long Island
    Posts
    696
    Quote Originally Posted by dportas
    I agree with blindman. It seems that you have an administrative problem (and possibly a design problem also) for which you have already concluded a script is the best solution, so what you've posted here is a request for a script.

    Also, it's inaccurate to say that DTS "allows" only one DB at a time (whatever that is supposed to mean).

    DTS accepts a Global variable as input DTSRun /A

  9. #9
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    That would be a good solution, as would looping in the package.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •