George,
Try SMO.
The assembly Microsoft.SqlServer.Smo.dll (and supporting DLLs
Microsoft.SqlServer.ConnectionInfo.dll and Microsoft.SqlServer.SmoEnum.dll
etc) can be found in C:\Program Files\Microsoft SQL Server\90\SDK\Assemblies.
Have a look at the Server (server.AttachDatabase and server.DetachDatabase),
Backup and Restore classes.
SMO is also backward compatible with SQL Server 2000 and 7 (but with reduced
functionality).
All the best.
Phil.
"George Shubin" wrote:
Using SQL Server 2005 Express.
I need to periodically duplicate an entire database and rename it. Most
tables are empty but some are to be prepopulated. I was thinking of having
a "template" database called perhaps "EmptyDatabase", and then copy that
into a freshly created database with a new name.
Has anyone coded anything like this?
Thanks.
GS