{"id":142,"date":"2009-05-20T19:02:00","date_gmt":"2009-05-20T19:02:00","guid":{"rendered":"http:\/\/turtlellc.com\/index.php\/find-which-tables-contain-a-column-and-the-information_schema-namespace\/"},"modified":"2009-05-20T19:02:00","modified_gmt":"2009-05-20T19:02:00","slug":"find-which-tables-contain-a-column-and-the-information_schema-namespace","status":"publish","type":"post","link":"https:\/\/www.turtle.works\/knowledge\/find-which-tables-contain-a-column-and-the-information_schema-namespace\/","title":{"rendered":"Find Which Table(s) Contain a Column and the INFORMATION_SCHEMA Namespace."},"content":{"rendered":"<p>To find which table(s) contain the PersonID column try this:<\/p>\n<p>SELECT TABLE_NAME<br \/>FROM INFORMATION_SCHEMA.COLUMNS<br \/>WHERE COLUMN_NAME LIKE &#8216;%PersonID%&#8217;<\/p>\n<p>In the AdventureWorks DB this is what you see:<br \/><img decoding=\"async\" src=\"file:\/\/\/C:\/DOCUME%7E1\/jwainz\/LOCALS%7E1\/Temp\/moz-screenshot.jpg\" alt=\"\" \/><br \/><a onblur=\"try {parent.deselectBloggerImageGracefully();} catch(e) {}\" href=\"http:\/\/4.bp.blogspot.com\/_shI7YV88LjI\/ShRZ2kfbL9I\/AAAAAAAAACM\/NwfslhU75eM\/s1600-h\/INFORMATION_SCHEMA.COLUMNS.JPG\"><img decoding=\"async\" style=\"cursor: pointer; width: 297px; height: 303px;\" src=\"http:\/\/4.bp.blogspot.com\/_shI7YV88LjI\/ShRZ2kfbL9I\/AAAAAAAAACM\/NwfslhU75eM\/s400\/INFORMATION_SCHEMA.COLUMNS.JPG\" alt=\"\" id=\"BLOGGER_PHOTO_ID_5337990252384169938\" border=\"0\" \/><\/a><br \/>So of course you can search for any column, not just PersonID.<\/p>\n<p>Another interesting tidbit is that any ANSI compliant DBMS provides the INFORMATION_SCHEMA namespaces.  From this namespace you have access to the metadata on any DB object. You can look up information on Stored Procedures and Functions using INFORMATION_SCHEMA.ROUTINES or use any of the many different objects within this namespace: COLUMNS, ROUTINES, CHECK_CONSTRAINTS, PARAMETERS, TABLES, etc.<\/p>\n<p>Enjoy<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To find which table(s) contain the PersonID column try this: SELECT TABLE_NAMEFROM INFORMATION_SCHEMA.COLUMNSWHERE COLUMN_NAME LIKE &#8216;%PersonID%&#8217; In the AdventureWorks DB this is what you see:So of course you can search for any column, not just PersonID. Another interesting tidbit is that any ANSI compliant DBMS provides the INFORMATION_SCHEMA namespaces. From this namespace you have access &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.turtle.works\/knowledge\/find-which-tables-contain-a-column-and-the-information_schema-namespace\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Find Which Table(s) Contain a Column and the INFORMATION_SCHEMA Namespace.&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25,26,28],"tags":[],"class_list":["post-142","post","type-post","status-publish","format-standard","hentry","category-sql","category-sql-server","category-t-sql"],"_links":{"self":[{"href":"https:\/\/www.turtle.works\/knowledge\/wp-json\/wp\/v2\/posts\/142","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.turtle.works\/knowledge\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.turtle.works\/knowledge\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.turtle.works\/knowledge\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.turtle.works\/knowledge\/wp-json\/wp\/v2\/comments?post=142"}],"version-history":[{"count":0,"href":"https:\/\/www.turtle.works\/knowledge\/wp-json\/wp\/v2\/posts\/142\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.turtle.works\/knowledge\/wp-json\/wp\/v2\/media?parent=142"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.turtle.works\/knowledge\/wp-json\/wp\/v2\/categories?post=142"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.turtle.works\/knowledge\/wp-json\/wp\/v2\/tags?post=142"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}