pyodbc icon indicating copy to clipboard operation
pyodbc copied to clipboard

Can't see DOMAIN_NAME values in INFORMATION_SCHEMA.COLUMNS

Open rc-ig opened this issue 1 year ago • 0 comments
trafficstars

Environment

  • Python: 3.11.10
  • pyodbc: 5.2.0
  • OS: Ubuntu 22.04.5 LTS
  • DB: MS SQL Server
  • driver: ODBC Driver 17 for SQL Server

Issue

I am querying a database that uses user defined types, as described in the SQL Server documentation. The table 'MyTable' has fields that use one of these user defined types.

Using Azure Data Studio, if I submit the query SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'MyTable' I get a response with one row per field in MyTable with the following columns:

TABLE_CATALOG
TABLE_SCHEMA
TABLE_NAME
COLUMN_NAME
ORDINAL_POSITION
COLUMN_DEFAULT
IS_NULLABLE
DATA_TYPE
CHARACTER_MAXIMUM_LENGTH
CHARACTER_OCTET_LENGTH
NUMERIC_PRECISION
NUMERIC_PRECISION_RADIX
NUMERIC_SCALE
DATETIME_PRECISION
CHARACTER_SET_CATALOG
CHARACTER_SET_SCHEMA
CHARACTER_SET_NAME
COLLATION_CATALOG
COLLATION_SCHEMA
COLLATION_NAME
DOMAIN_CATALOG
DOMAIN_SCHEMA
DOMAIN_NAME

The column DOMAIN_NAME contains the name of the user defined type where applicable, or NULL if a system defined type is used.

When I perform the same query using pyodbc, the response consists of 23 columns, but for every row the value in the DOMAIN_NAME field is None.

Is there anyway to determine where user defined types have been used in a table?

rc-ig avatar Nov 12 '24 12:11 rc-ig