pvds
(Hey THIS is FUN)
2005-07-19 09:00 AM
Attach DB files to MSDE

Hi,

Where can I find some info or example code to attach a .mdf and .log file to a new installation of msde?

have searched but missed the right one!!

Thanks Peter


Stevie
(Starting to like KiXtart)
2005-07-19 01:52 PM
Re: Attach DB files to MSDE

The easiest way is to use the Microsoft SQL-DMO COM objects. The object from that library you want to look at is SQLServer which contains a method called 'AttachDB'. It takes a multistring value to grab both the .mdb/.ldb files. Should give you just what you want.

Mart
(KiX Supporter)
2005-07-19 06:40 PM
Re: Attach DB files to MSDE

And that would be:

Code:

sp_attach_db 'Database name',
'path to data file\datafile.mdf',
'path to logfile\logfile.ldf'



Also see: MS page on SP_ATTACH_DB


Kdyer
(KiX Supporter)
2005-07-19 06:41 PM
Re: Attach DB files to MSDE

And this can be done outside of the regular GUI Tools using osql.

Kent


pvds
(Hey THIS is FUN)
2005-07-20 08:16 PM
Re: Attach DB files to MSDE

OK thanks,

Wil give the osql tool a try

Peter