english francais

Using oSQL to run the patch_db.sql or create_db.sql SQL scripts on your Microforge.net Enterprise Server database

How do I run an SQL script against my Microforge.net Enterprise Server database if I don't have access to Microsoft Enterprise Manager for SQL Server?

Article Details

You can use the osql command-line tool to access, query, or run scripts against, your SQL Server or MSDE database.  For example, to run the patch_db.sql script when upgrading your installation of Microforge.net Enterprise Server - after navigating to the Microforge.net \ Enterprise Server \ Tools directory - you could use the following command:

osql -S narcisus -d mf_enterprise -E -i patch_db.sql

  • -S narcisus specifies the server name to be "narcisus."  For a database on the local machine, specify either "(local)", or "(local)\[InstanceName]" if you are using a named instance.
  • -d mf_enterprise specifies the database name to be "mf_enterprise", the default database name for Microforge.net Enterprise Server
  • -E specifies that osql should use a trusted connection.  You could instead specify a username using the -U option.
  • -i patch_db.sql specifies the name of the script to be run

The following is a summary of command-line options for the osql command-line tool:

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]
  [-X[1] disable commands [and exit with warning]]
  [-O use Old ISQL behavior disables the following]
      <EOF> batch processing
      Auto console width scaling
      Wide messages
      default errorlevel is -1 vs 1
  [-? show syntax summary]