executing osql.exe

Posted on 2005-04-29
Last Modified: 2012-06-21
I am using osql command to execute a batch file to update my database

@echo off
osql.exe -d dbname -U username -P password -i C:\Program Files\Test Systems\Application Windows\Working\Batchfile.sql -Q

I am not sure to whether the command is executed correctly. Is it possible to write the output in a text file or see the result window?

Thanks in advance for your help
Question by:veshan
    LVL 14

    Accepted Solution

    Try this:

    osql.exe -d dbname -U username -P password -i C:\Program Files\Test Systems\Application Windows\Working\Batchfile.sql -o C:\Program Files\Test Systems\Application Windows\Working\Batchfile.log -Q

    Author Comment

    Thanks a lot.
    Does blank spaces (C:\Program Files\Application Windows\...\ in the file path ?
    LVL 14

    Expert Comment

    Yes, the blank spaces could cause you a problem - enclose it in ":

    osql.exe -d dbname -U username -P password -i "C:\Program Files\Test Systems\Application Windows\Working\Batchfile.sql" -o "C:\Program Files\Test Systems\Application Windows\Working\Batchfile.log" -Q

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    This is my first ever Article on EE or elsewhere; therefore, please bear with me if I have some discrepancies in my writing. I read many articles and questions related to "how to pass values to SSIS packages at run-time?"  Hence, this common ques…
    Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
    Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
    Viewers will learn how the fundamental information of how to create a table.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now