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.
Best Answer
Here are a few suggestions
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.