<jo*************@yahoo.com> wrote in message
news:11*********************@l41g2000cwc.googlegro ups.com...
Will osql product an SQL backup? By this I mean a text file with the
transact-sql in it so I can use it to recreate the database elsewhere?
Thank you.
No - if you want to generate .sql scripts to recreate a database and its
objects, you need to use Enterprise Manager or Query Analyzer, or write your
own code to use the SQLDMO API. But if you just want to backup the database
to a backup file, so you can restore it later, then yes:
osql -S MyServer -E -Q"backup database MyDB to disk = 'c:\temp\mydb.bak'"
Then copy mydb.bak to the target server and restore it:
osql -S MyServer -E -Q"restore database MyDB from disk = 'c:\temp\mydb.bak'"
You might find these links helpful (I'm guessing you have MSDE since you
want to use osql.exe specifically):
http://support.microsoft.com/default...b;en-us;314546 http://www.aspfaq.com/show.asp?id=2442
Simon