I'm trying to execute this script through JDBC (it's SQL Server):
DECLARE @var VARCHAR(10)
SET @var = "test"
INSERT INTO foo (name) VALUES (@var)
It's just an example, in my business case I have a big collection of SQL statements in one script.
I'm trying this:
final Statement stmt = connection.createStatement();
for (String sql : lines) {
stmt.executeUpdate(sql);
}
stmt.close();
SQL Server is saying on the second line:
java.sql.SQLException: Must declare the scalar variable "@var".
Looks like I'm doing something wrong...