From 146efafcb436660e7891d3b34d05cd794c45268d Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 5 Feb 2021 09:34:25 -0500 Subject: [PATCH] Precede sp_columns with EXEC Fixed issue regarding SQL Server reflection for older SQL Server 2005 version, a call to sp_columns would not proceed correctly without being prefixed with the EXEC keyword. This method is not used in current 1.4 series. Fixes: #5921 Change-Id: I2ffcda97d570879719ec5c1ea9fb7507dc87756f --- doc/build/changelog/unreleased_13/5921.rst | 9 +++++++++ lib/sqlalchemy/dialects/mssql/base.py | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 doc/build/changelog/unreleased_13/5921.rst diff --git a/doc/build/changelog/unreleased_13/5921.rst b/doc/build/changelog/unreleased_13/5921.rst new file mode 100644 index 0000000000..90600a4bd8 --- /dev/null +++ b/doc/build/changelog/unreleased_13/5921.rst @@ -0,0 +1,9 @@ +.. change:: + :tags: bug, mssql, reflection + :tickets: 5921 + + Fixed issue regarding SQL Server reflection for older SQL Server 2005 + version, a call to sp_columns would not proceed correctly without being + prefixed with the EXEC keyword. This method is not used in current 1.4 + series. + diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py index bab3943247..22f3297308 100644 --- a/lib/sqlalchemy/dialects/mssql/base.py +++ b/lib/sqlalchemy/dialects/mssql/base.py @@ -17,7 +17,7 @@ External Dialects In addition to the above DBAPI layers with native SQLAlchemy support, there are third-party dialects for other DBAPI layers that are compatible with SQL Server. See the "External Dialects" list on the -:ref:`dialect_toplevel` page. +:ref:`dialect_toplevel` page. .. _mssql_identity: @@ -2750,7 +2750,7 @@ class MSDialect(default.DefaultDialect): # We also run an sp_columns to check for identity columns: cursor = connection.execute( sql.text( - "sp_columns @table_name = :table_name, " + "EXEC sp_columns @table_name = :table_name, " "@table_owner = :table_owner", ), {"table_name": tablename, "table_owner": owner}, -- 2.47.3