Use of osql

  • Hi All,

    I am using the following command which should create a new database in the server.

    osql -E -S (local)\NetSDK -i InstPubs.sql

    I am runnig this command from the command prompt. But its not creating the databaes. I tried by giving the all the paths also. Any idea why its not working?.

    Thanks

    jai

  • What error message are you getting?

    --

    Chris Hedgate @ Apptus Technologies (http://www.apptus.se)

    http://www.sql.nu

  • Thanks for your reponse. I am not getting any error messages. Its runnign for a minute and completing. But when i check in the query analyzer, the database is not showing up. The sql script suppose to create a database on the server.

    Thanks

    Jai

  • What does the script look like? Is it pubs you are trying to create? What happens if you run the same script in query analyzer?

    --

    Chris Hedgate @ Apptus Technologies (http://www.apptus.se)

    http://www.sql.nu

  • o What database are you wanting the script to run it? Does the script control that?

    o Did you test the script in QA? What were your results there?

    o Try specifing the database in the ISQL line to be master.

    Edited by - chief78cj7 on 03/17/2003 12:22:41 PM

  • From BOL :

    quote:


    The osql utility passes everything between the parentheses ( ) to the server exactly as entered. If a stored system procedure selects a set and returns a value, only the selection is returned. The EXIT( ) statement with nothing between the parentheses executes everything preceding it in the batch and then exits with no return value.

    There are four EXIT formats:

    EXIT

    Does not execute the batch; quits immediately and returns no value.

    EXIT( )

    Executes the batch, and then quits and returns no value.

    EXIT(query)

    Executes the batch, including the query, and then quits after returning the results of the query.

    RAISERROR with a state of 127

    If RAISERROR is used within an osql script and a state of 127 is raised, osql will quit and return the message ID back to the client. For example:

    RAISERROR(50001, 10, 127)


    Make certain if raising any errors use a state of 127. Not sure if this helps, but with a normal raiserror the error will not propogate outside of the osql call unless you do.

    Tim C.

    //Will write code for food


    Tim C //Will code for food

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply