Sunday, February 12, 2012

attaching a .mdf file to the MSSQL 2000 using commandline

Hi ,

we have a requirement to create a database of our application in client's system. and we assume that already MS Sql server is installed.

we have a .mdf file of our database. Is there any way I can attach .mdf file to the database using command line. so that I can write a batch file and run that batch to create the database in our client's system.

-regards

GRK

you can use SQL scripting method. If it is sql server 2005 then use SQLCMD -q and if it is sql server 2000 then use OSQL -q option.

Madhu

|||

Look in Books Online about the usage of [ sp_attach_single_file ].

|||

thanks Arnie,

its working. I used the [sp_attach_single_file] with osql from the command prompt and created a database.

-regards

GRK

No comments:

Post a Comment