Is there a way to display PRINT results with SQL server JDBC driver?

后端 未结 3 596

If my stored procedure has a print statement inside it:

print \'message\'

Is there a way to fetch the output in java program that connects

3条回答
  •  半阙折子戏
    2021-01-06 07:55

    Yes, there is: https://dba.stackexchange.com/a/44373/5457

    Statement stmt = ...;
    stmt.execute("some sql statement");
    SQLWarning warning = stmt.getWarnings();
    
    while (warning != null) {
        System.out.println(warning.getMessage());
        warning = warning.getNextWarning();
    }
    

提交回复
热议问题