Microsoft KB Archive/280109

From BetaArchive Wiki
Knowledge Base


The PRINT, RAISERROR, DBCC commands and the ODBC Driver for SQL Server 2000 and SQL Server 7.0

Article ID: 280109

Article Last Modified on 12/21/2004



APPLIES TO

  • Microsoft SQL Server 2000 Standard Edition
  • Microsoft SQL Server 7.0 Standard Edition



This article was previously published under Q280109

SUMMARY

For the ODBC 3.5x compliant SQL Server driver, messages from consecutive PRINT, RAISERROR, DBCC, or similar statements, as in a batch or stored procedure, are returned in a separate result set for each statement.

MORE INFORMATION

With Microsoft SQL Server 6.x and 2.x ODBC driver, messages from consecutive PRINT, RAISERROR, DBCC, or similar statements as in a batch or stored procedure were combined into a single result set. However, for the ODBC 3.5x compliant SQL Server driver (provided with SQL Server 2000 or SQL Server 7.0), the messages from these consecutive statements are returned in separate result sets. To process the results of these commands, use the SQLMoreResults statement.

For example:

SQLExecDirect(hstmnt,"PRINT 'SomeMessage1'",SQL_NTS)
SQLExecDirect(hstmnt,"PRINT 'SomeMessage2'",SQL_NTS)
                

The first call to SQLERROR returns:

SQL_SUCCESS=0
*szSqlState = "01000", *pfNativeError = 0, *szErrorMsg = "[Microsoft][ODBC SQL Server Driver][SQL Server]SomeMessage1"
                

Then, a call to SQLMoreResults returns:

SQL_SUCCESS_WITH_INFO
                

The immediate call to SQLERROR returns:

SQL_SUCCESS=0
*szSqlState = "01000", *pfNativeError = 0, *szErrorMsg = "[Microsoft][ODBC SQL Server Driver][SQL Server]SomeMessage2"
                


REFERENCES

For additional information, click the article number below to view the article in the Microsoft Knowledge Base:

140696 INF: RAISERROR, PRINT, and the MS SQL Server ODBC Driver



Additional query words: PRINT RAISERROR DBCC

Keywords: kbinfo kbdatabase KB280109