Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 74993

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:26:46+00:00 2026-05-10T20:26:46+00:00

I am currently using osql with nant by calling a batch file with arguments.

  • 0

I am currently using osql with nant by calling a batch file with arguments. Here are the properties that are defined in my nant script (no, not real username/password values):

<property name='project.config' value='debug' /> <property name='server' value='(local)' /> <property name='database' value='Test' /> <property name='username' value='sa' /> <property name='password' value='password' /> 

I then create the osql connection based on the username/password:

<if test='${username==''}'>   <property name='osql.connection' value='-E' /> </if> <if test='${username!=''}'>   <property name='osql.connection' value='-U ${username} -P ${password}' /> </if> 

I then pass these values onto my batch file:

<exec program='setup.bat'>    <arg value='${server}'/>    <arg value='${database}' />    <arg value='${osql.connection}' /> </exec> 

The setup.bat file uses osql to drop the database:

osql -S %1 -d master %3 -Q 'IF EXISTS (SELECT * FROM sysdatabases WHERE name = N'%2') DROP DATABASE [%2]' 

This works fine if I do not pass a username/password to the nant script and use integrated security instead (‘-E’ to osql). If I do specify a username/password, then the nant script just pauses (like it is awaiting some input). I do know that I am specifying the correct username/password as I can log into SQL Connection Manager and delete the database.

Please let me know if there are any suggestions on what to try or alternate ways to do this.

Related Questions

No related questions found

  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T20:26:46+00:00Added an answer on May 10, 2026 at 8:26 pm

    Here are a few suggestions

    1. To help diagnose the problem with the nant/batch script it would be helpful to echo out the full osql command (from the batch script) that is being executed. This is of course to make sure the osql.connection is being expanded properly when a username/pass is provided.
    2. There maybe other reasons you are using a batch script that we are not privy to. However, to help diagnose the problem you can use the exec task directly passing in osql.exe as the program. Again, this is just to take out the batch script to see if it works by using osql.exe directly. Also, with that you’ll be able to echo out the entire command string prior to executing, using the echo task.
    3. For a completely different approach, you can try the sql task which is part of the NAntContrib distribution. Many times, it makes for a very nice alternative to osql.exe.

    Maybe by trying some of these you’ll be able narrow down what exactly is going on. Post your findings in the comments and I’ll be happy to try and help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 58k
  • Answers 58k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer From VS to launch PSH with an extra script (for… May 11, 2026 at 8:40 am
  • added an answer Finalizers aren't called before GC.Collect() returns. The finalizers are run… May 11, 2026 at 8:40 am
  • added an answer You are stepping into the shoes of Raymond Chen. He… May 11, 2026 at 8:40 am

Top Members

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.