• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2639
  • Last Modified:

Differences when using osql vs sqlcmd

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.
0
jpelldev
Asked:
jpelldev
1 Solution
 
authentifyCommented:
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.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now