>>>I need to "move" a bunch of databases from one computer to another. I have created backup of all databases to an external drive. That is, the external drive now has several .BAK files. Do I need to create the databases on the target computer before I can restore from the .BAK files? Or can I restore and create database from .BAK in one step?
>>>
>>>TIA
>>
>>In order to write a script that would restore all databases from a certain folder - without hard-coding each database name - I would need to scan all files with extension *.BAK. How can I create a cursor and scan all files from a folder into the cursor (using T-SQL)?
>>Or is there a better way to approach the task?
>I frequently have to move DB's, so I wrote some VFP and .NET programs that do that.
>Are you committed to TSQL for some special reason?
>This is an easy task using VFP with SPT or .NET.
>You can write one program to do the backups and the restores.
I do my SQL Databases backups with a simple TSQL script. As far as restoring, this is a one-time procedure I need to do, in order to move my databases to a new computer. I believe that, unless I was using VFP and .NET (as you do) for creating backup and restore all the time, for me now doing it in TSQL is simpler. I am reading a couple of on-line articles on understanding various options and choices when restoring a DB. Once I understand it, writing a TSQL script won't be that difficult.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham