title: Execute SQL query using Groovy script
body: <p>I am trying to run SQL update query using Groovy script.</p>
  
  <pre><code>//Global Properties Value
  def dbServer = context.expand('${#Project#DB_Server}')
  def dbPort = context.expand('${#Project#DB_Port}')
  def dbName = context.expand('${#Project#DB_Name}')
  def dbUser = context.expand('${#Project#DB_Username}')
  def dbPass = context.expand('${#Project#DB_Password}')
  def userID = context.expand('${#Project#userID}').toInteger()
  
  //Convert HEX to Integer
  def userSerialHex = context.expand('${#Project#userSerial}').toString();
  BigInteger userSerialInteger = Long.parseLong(userSerialHex, 16);
  
  log.info userSerialHex
  log.info userID
  log.info userSerialInteger
  
  //Connection String
  def con = Sql.newInstance("jdbc:sqlserver://$dbServer:$dbPort;" + "databaseName=" + dbName, dbUser, dbPass, 'com.microsoft.sqlserver.jdbc.SQLServerDriver')
  
  //SQL Query
  con.execute("update tblUserCardDetail set active=0 where fkUserID = $userID and cardValue = $userSerialInteger");
  </code></pre>
  
  <p>Result :</p>
  
  <pre><code>Fri Dec 08 20:24:25 IST 2017:INFO:182A11A53C68BD3C
  Fri Dec 08 20:24:25 IST 2017:INFO:12901
  Fri Dec 08 20:24:25 IST 2017:INFO:1741223607312891196
  </code></pre>
  
  <p>Expected : It should return true and update the row.</p>
  
  <p>Error i am getting :</p>
  
  <blockquote>
    <p>com.microsoft.sqlserver.jdbc.SQLServerException: The conversion from UNKNOWN to UNKNOWN is unsupported. error at line: 27</p>
  </blockquote>
  
  <p>When i run the query from sql server then it updated successfully.</p>
  
  <pre><code>update tblUserCardDetail set active=0 where fkUserID=12901 and cardValue=1741223607312891196
  </code></pre>