I have a sql statement that returns no hits. For example, \'select * from TAB where 1 = 2\'
.
I want to check how many rows are returned,
cu
You can do like this :
count = 0
cnxn = pyodbc.connect("Driver={SQL Server Native Client 11.0};"
"Server=serverName;"
"Trusted_Connection=yes;")
cursor = cnxn.cursor()
cursor.execute(SQL query)
for row in cursor:
count = 1
if true condition:
print("True")
else:
print("False")
if count == 0:
print("No Result")
Thanks :)