Tuesday, February 09, 2010

Strange error from Sql Server

ErrorMessage:
While trying to extract DDL and Data sql scripts using the Database publishing Wizard

Could not load file or assembly 'Microsoft.SqlServer.BatchParser, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Solution:
This is due to a problem with Microsoft.SqlServer.BatchParser.dll on Windows 64-bit.


Download and install


This installs the 64 bit smo objects.

ErrorMessage:
com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '@P0'.
Solution
This was a simple one.

This was my JDBC call
PreparedStatement ps = dbConnection.prepareStatement("insert into master_key (key_value) values ?");
ps.setString(1, key);
int id = ps.executeUpdate();

Problem was the missing '()' in the Sql

PreparedStatement ps = dbConnection.prepareStatement("insert into master_key (key_value) values (?)");