Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I use a command line to attatch

Status
Not open for further replies.

msg83

IS-IT--Management
Sep 18, 2002
20
0
0
US
Can I use a command line to attatch a database. Basically what I need to do is kick off a batch file to attach a DB in MS slq server. If i can do it then what would be the syntax for that.

 
Refer to the BOL and look up OSQL utility.

Basically, it would be:

C:>osql -E -S servername -Q "exec sp_attach_db 'dbname'"

-E = use a trusted account
-S = SQL Server server name
-Q = query to run and then exit. Wrap the command in DOUBLE quotes and any variables in single quotes.

-SQLBill

Posting advice: FAQ481-4875
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top