views:

385

answers:

2

By default SQL Server JDBC driver returns result set of all SELECT query executed in a stored procedure. I have to call CallableStatement.getMoreResults() and close all of them. I do not want any result set as return value when executing SQL Server stored procedurel; are there any ways to prevent returning result set when executing SQL Server stored procedure?

A: 

I'm not sure I understand. Are you executing select statements within your procedure that you don't want returned? Is it the rows affected that is being returned that is the result set you don't want? If its the latter you can add SET NOCOUNT ON to the beginning of the procedure to keep the rows affected from being returned.

Gratzy
SELECT statements returned as result set. I am using CallableStatement statement = cx.prepareCall(ProcedureSQL)
Venkat
NOCOUNT ON didn't work for me.
Venkat
A: 
 statement.executeUpdate()

should execute your sql without returning a resultset.

alasdairg
currently I am using CallableStatement statement = cx.prepareCall(ProcedureSQL); will give a try with executeUpdate()
Venkat
When trying with executeUpdate to run stored procedure it throws exception:com.microsoft.sqlserver.jdbc.SQLServerException: INSERT/UPDATE cannot be executed, please retry.
Venkat