Database backup

Last Post 26 Nov 2008 06:36 AM by plugsharma. 1 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
plugsharma
New Member
New Member

--
25 Nov 2008 04:23 AM
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


    plugsharma
    New Member
    New Member

    --
    26 Nov 2008 06:36 AM
    Hi Russel,

    Thanks for reply.

    This script is marvelous and working fine. It'll take some time for me to understand this script.

    I want to make the 'EmpID' as PK with identity yes and increment 1 and identity seed as 100000. Can you please modify the script and into a stored procedure. I am very weak in stored procedure.

    Thanks dude.

    Sharma

    You are not authorized to post a reply.

    Acceptable Use Policy