I'm trying to get the warning message from SQL Server's Raiserror in python with PyODBC.
The severity is low on purpose, because it acts as a printing functionality, but it doesn't have to wait until the query is done before printing.
The output I expect would be something like:
*Test Message*
|col1|
|:-|
|1|
Here's my code:
import pyodbc
conn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER=ECH-DWPROD02;DATABASE=Test;Trusted_Connection=yes;')
cursor = conn.cursor()
cursor.execute("SET NOCOUNT ON; RAISERROR('Test Message',0,1) WITH NOWAIT; select 1 as col1")
cursor.fetchall()