Differences when using osql vs sqlcmd

Posted on 2007-10-17
Last Modified: 2008-01-09
I am running a stored procedure which produces a report via a batch process.  In the past I have used the osql command.  After implementing SQL Server 2005, I was asked to use sqlcmd instead.

OLD Statement
osql -E  -S EMISTEST -d DCRVW000 -Q usp_act_MEM_Load_Balances_custval -o \\AVST404\EMIS_Batch\Finance\Actuals_CustVal\Act_Mem_Val\X18Y_FBP_Act_Mem_Val_10172007_132822_Report_1.txt  

NEW Statement
sqlcmd -E  -S EMISTEST -d DCRVW000 -Q usp_act_MEM_Load_Balances_custval -o \\AVST404\EMIS_Batch\Finance\Actuals_CustVal\Act_Mem_Val\X18Y_FBP_Act_Mem_Val_10172007_132822_Report_1.txt

The old method creates a report text file correctly but the new method does not.  Also, the batch processing just seems to stop.  It does not process any routines that are called after the statement to process the stored procedure.  

I know that I can just use the old method for now but I am being asked to explain why the new method does not work and I cannot determine the reason.
Question by:jpelldev
    1 Comment
    LVL 1

    Accepted Solution

    My first guess is permissions. Make sure that whomever is operating that batch file has permission to create a file in the target folder. Many of the permissions we used to take for granted in older versions are all turned off in the new version.
    Try the proc in a query window or a DOS box by hand so you can see what's happening.
    OSQL and SQLCMD are supposed to be functionaly equivalent so if it worked before, it ought to work now.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
    Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    737 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

    18 Experts available now in Live!

    Get 1:1 Help Now