Groups | Blog | Home
all groups > sql server odbc > july 2007 >

sql server odbc : Using T-SQL Print with ODBC


seijin NO[at]SPAM gmail.com
7/10/2007 7:57:43 AM
Is it possible to return messages from T-SQL using ODBC?

For example, I'm running the following basic example from Wikipedia on
T-SQL...

DECLARE @Counter INT
SET @Counter = 10
WHILE @Counter > 0
BEGIN
PRINT 'The count is ' + CONVERT(VARCHAR(10), @Counter)
SET @Counter = @Counter - 1
END

SQLGetDiagField() says there is only 1 record and SQLGetDiagRec() only
returns the very first bit of information: "[Microsoft][ODBC SQL
Server Driver][SQL Server]The count is 10" It doesn't count down with
more messages.

What am I doing wrong?
Mark Yudkin
7/15/2007 12:00:00 AM
You're supposed to call SQLGetDiagRec until it returns SQL_NO_DATA.
SQLGetDiagField is a read herring in this context.

[quoted text, click to view]

Dennis Black
7/18/2007 12:47:16 PM
I tried running your SQL script through WinSQL and it returned all 10
lines. Try turning on ODBC tracing with WinSQL and see how is that able
to return all 10 lines.






[quoted text, click to view]
AddThis Social Bookmark Button