ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jakob Fix" <jakob....@gmail.com>
Subject problem using sqlcmd with ant
Date Fri, 27 Jun 2008 09:06:02 GMT
Hi,

we're trying to execute a bunch of sql commands on MS SQL Server 2000
with ant and sqlcmd -- sqlcmd because ant's built-in sql task doesn't
allow for trusted connections, or am I wrong?.

<project name="exp"	basedir=".">
	<property name="DBName" value="SV3"/>
	<property name="ServerName" value="DB-NTSERVER"/>
	<property name="OutputDirectory" value="."/>
	<property name="InputDirectory" value="."/>
	<target name="sql.exp">
		<exec executable="sqlcmd" error="error.log" output="output.log">
			<arg value="-S ${ServerName}"/>
			<arg value="-d ${DBName}"/>
			<arg value="-o &quot;${OutputDirectory}&quot;"/>
			<arg value="-i &quot;${InputDirectory}\script.sql&quot;"/>
			<arg value="-E"/><!-- use trusted connection -->
		</exec>
	</target>
</project>


P:\>antTest.bat
Unable to locate tools.jar. Expected to find it in C:\Program
Files\Java\jre1.6.0_06\lib\tools.jar
Apache Ant version 1.7.0 compiled on December 13 2006
Buildfile: build.xml
Detected Java version: 1.6 in: C:\Program Files\Java\jre1.6.0_06
Detected OS: Windows 2003
parsing buildfile P:\build.xml
Project base dir set to: P:
[antlib:org.apache.tools.ant] Could not load definitions from resource
org/apache/tools/ant/antlib.xml. It could not be found.
Build sequence for target(s) `sql.exp' is [sql.exp]
Complete build sequence is [sql.exp, ]

sql.exp:
     [exec] Current OS is Windows 2003
     [exec] Output redirected to P:\output.log
     [exec] Error redirected to P:\error.log
     [exec] Executing 'sqlcmd' with arguments:
     [exec] '-S DB-NTSERVER'
     [exec] '-d SV3'
     [exec] '-o "P:\output.txt"'
     [exec] '-i "P:\script.sql"'
     [exec] '-E'
     [exec]
     [exec] The ' characters around the executable and arguments are
     [exec] not part of the command.
     [exec] Result: 1

BUILD SUCCESSFUL
Total time: 0 seconds
P:\>


P:\> more error.log
Sqlcmd: '-S DB-NTSERVER': Unknown Option. Enter '-?' for help.

We tried running the command line on its own, and it worked OK (see
below).  However, as soon as we execute the above ant script, even
though ant executes successfully, but we get a return result of 1, and
the above error message in the error output file.

P:\>Sqlcmd -E -S DB-NTSERVER -d SV3 -i "script.sql"
Msg 2705, Level 16, State 4, Server PUB-NTSERVER, Line 6
Column names in each table must be unique. Column name 'OrderNumber'
in table 'Product' is specified more than once.

BTW, This message is expected and shows us that the connection to the
database was successful.

Thanks for any help you may give.


-- 
cheers,
Jakob.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message