Python 3.6和noob:
在我的代码中,我有:
import pyodbc
cnxn= pyodbc.connect(
server='SQL_server_name.server.domain.net,1433',
driver='{ODBC Driver 13 for SQL Server}',
database='DB_NAME',
trusted_connection = 'yes')
cursor = cnxn.cursor()
cursor.execute(" SELECT * FROM trust_domain WHERE trust = 1 ")
print(cursor.fetchall())
但是当我为相同的查询运行SQL Profiler时,我得到了。
SELECT * FROM [trust_domain] WHERE [trust]=@1
在许多SQL查询中,“ @”是由数字或占位符或整个字符串
另一个例子: 实际的SQL:
SELECT *
FROM entries
WHERE domain LIKE 'domain_name' AND active = 1 AND archive = 0 AND userid LIKE 'testid'
ORDER BY date_active_on DESC
SQL事件探查器:
SELECT *
FROM entries
WHERE domain LIKE @P1 AND active = 1 AND archive = 0 AND userid LIKE @P2
ORDER BY date_active_on DESC