Skip to content

Instantly share code, notes, and snippets.

@corneil
Created September 3, 2021 05:53
Show Gist options
  • Save corneil/6462e88b3833c68b0835b37774d5f44f to your computer and use it in GitHub Desktop.
Save corneil/6462e88b3833c68b0835b37774d5f44f to your computer and use it in GitHub Desktop.
Find a DB2 table name and column from SQLCODE=-407, SQLSTATE=23502
SELECT C.TABSCHEMA, C.TABNAME, C.COLNAME
FROM SYSCAT.TABLES AS T, SYSCAT.COLUMNS AS C
WHERE T.TBSPACEID = -- TBSPACEID
AND T.TABLEID = -- TABLEID
AND C.COLNO = -- COLNO
AND C.TABSCHEMA = T.TABSCHEMA
AND C.TABNAME = T.TABNAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment