« Redistributing MSDE and the .NET Framework | Main | MSDE Detach Tricks »

MSDE management using OSQL

HOW TO: Manage the SQL Server Desktop Engine (MSDE 2000) by Using the Osql Utility

C:\>osql -?

usage: osql              [-U login id]          [-P password]

  [-S server]            [-H hostname]          [-E trusted connection]

  [-d use database name] [-l login timeout]     [-t query timeout]

  [-h headers]           [-s colseparator]      [-w columnwidth]

  [-a packetsize]        [-e echo input]        [-I Enable Quoted Identifiers]

  [-L list servers]      [-c cmdend]            [-D ODBC DSN name]

  [-q "cmdline query"]   [-Q "cmdline query" and exit]

  [-n remove numbering]  [-m errorlevel]

  [-r msgs to stderr]    [-V severitylevel]

  [-i inputfile]         [-o outputfile]

  [-p print statistics]  [-b On error batch abort]

 

C:\>osql –Q -S (local)\JobQuake -U sa -P

C:\>osql –Q -S (local)\JobQuake -E

 

C:\>osql -S (local)\JobQuake -U sa -P

 

exec sp_password null, 'bojekauq', 'sa'

create database JobSearch on (NAME='js_data', FILENAME='c:\js.mdf', SIZE=1, FILEGROWTH=10%) LOG ON (NAME='js_log', FILENAME='c:\js.ldf', SIZE=1, FILEGROWTH=10%) COLLATE SQL_Latin1_General_CP1_CI_AS

create database JobSearch on (NAME='js_data', FILENAME='c:\js.mdf', SIZE=1, FILEGROWTH=10%) COLLATE SQL_Latin1_General_CP1_CI_AS

Creates the file c:\js_log.LDF as the log file.

backup database JobSearch TO DISK='c:\js.bak'

restore database JobSearch from disk='c:\js.bak'

exec sp_detach_db 'JobSearch'

exec sp_attach_single_file_db 'JobSearch', 'c:\js.mdf'

C:\>osql -L

 

Servers:

    (local)

    BLASTER

    KIRA\JOBQUAKE

    OSIRIS\VSdotNET

    PELL

    PELL\JOBQUAKE

    PELL\VSdotNET

 

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)