I want to thank you all, who, one way or another, have helped me shed some light about how I can deploy a SQL Database to another instance of SQL server, or another machine, by just using the database data and log files. Apparently there is no Delphi methods to accomplish such tasks. As Jeremy suggested out, someone should be able to create a wrapper for the SQL DMO or SMO active X objects. But, I lack of the required experience with MS SQL server to be that someone. However, other participants have suggested the simpler route of ADOCommand used in conjunction with MS T-SQL commands. Jeremy inspired me to run a search through the SQL 2K5 books online, that reveals a way to use the so common CREATE DATABASE SQL command to deploy databases to other machines, or instances on the same machine:
USE [master] GO CREATE DATABASE [database_name] ON ( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1 \Data\<database name>.mdf' ), ( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1 \Data\<database name>.ldf' ) FOR ATTACH; GO Instead of the USE command, in Delphi, we may find it more practical to create a connection object that will connect to the master database, before executing the Create Database command. Personally, I believe that this is the simplest way to achieve the task I was contemplating, and think appropriate to share it with you. Luthfi Hakim has even added some spices by unveiling the existence of system store procedures such as sp_attach_db and sp_attach_single_file_db. I haven't got a chance to double check the presence of such SP in SQL 2K, or 2K5. But, I tend to agree with Luthfi that the VB command AttachDatabase is nothing but a wrapper for the T-SQL approaches. Once again, thank you all! Emmanuel --- In advanced_delphi@yahoogroups.com, "Emmanuel Lamy" <[EMAIL PROTECTED]> wrote: > > Hi everybody, > > Anyone knows if there is a Delphi method that accomplishes the same > action as the VB "AttachDatabase" method that the VB programer can use > to "attach" an existing database defined by one or several files to a > defined instance of SQL Server? Or better, is there an alternative as > to register an external SQL database file with another instance of a > SQL Server, or SQL Express? Any hint or suggestions welcome. TIA. > > Emmanuel >