script for backup files

  • Hi All,

    If Suppose f: having the a.bak

    b.bak

    c.bak

    d.bak

    like that some files(only backup files not a log).

    so what is my requirement is I wanna T-sql script for

    1.reading the all the bak files

    2.And restore those bak files using with move option

    Remember that if i run the script means i will get the output dynamically

    could anybody give that script..

    Any help will be greatly appreciated..

    Thanks in advance

  • This isn't quite clear. Are you saying that you have full backups of multiple databases in a folder and you want to restore these backups to new copies of the databases using with MOVE?

    There are a few things here. How are the database names changing? Or does that not matter? You mention with MOVE, are you thinking that all the mdf/ldfs will live in the default pathing with new names , or you need new names?

  • Hi Steve,

    Thanks for quick reply.

    What im asking is i have an backup files already for multiple databases..

    so based upon those .bak files automatically restore should happened using with move option.Database name is not a matter whether it will be same or different not a propblem..And all the mdf/ldfs will live in the default pathing with new names ..

    To make simplify ,I want to script that will generates restoration of databases using .bak files..

    Steve could you give me that script

    Thanks in advance

  • Use the GUI to set up the restore, then use the "script" function to create your script based on what you chose in the GUI. You could then put that script into a scheduled job if that's what you want.

  • So, you're still saying this is simple, but it's not as simple as you ask.

    If this is the same server instance, then names matter. If this is another instance, then names don't matter, but you have to be careful of where you run this.

    In terms of with WITH MOVE, why is that needed? If it's a new server instance, then you don't need WITH MOVE, but if you use it, you have to determine what parameter are you taking in. Is it the drive letter? Or the full path?

    This script might help you:

    http://www.sqlservercentral.com/scripts/Backup+%2f+Restore/31995/

    If it doesn't, then you can search our scripts section for "restore"

  • Hi Steve,

    Thanks...The link(regarding script) what you gave was really help to me..

    But I have to modify as per my requirement..any way thanks to you.

    Now i want to another script for

    1.In a single server go to the all my databases

    2.If suppose database name called db1 .db1 having the 20 users .

    so go to the db1 and verify what are the permissions those 20 users have..

    3.Like that go to each database and verify the permissions for all users

    Thanks in advance

  • Please start a new thread for new questions.

    Also, you need to think about what you mean by verify. There is no such thing in SQL Server, so there's no way for us to determine what verify means until you define it.

Viewing 7 posts - 1 through 6 (of 6 total)

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