Skip to content

Instantly share code, notes, and snippets.

@mrandrewmills
Created September 17, 2019 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrandrewmills/b5c3cc779872d07be9017566443caca2 to your computer and use it in GitHub Desktop.
Save mrandrewmills/b5c3cc779872d07be9017566443caca2 to your computer and use it in GitHub Desktop.
When you don't have DB access, but need to see the tables & field names with which you are working.
<!--- change datasource as needed --->
<cfset thisDatasource = "example">
<!--- retrieve and display all table names in order --->
<cfquery name="getAllTableNames" datasource="#thisDatasource#">
SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE'
ORDER BY Table_Name
</cfquery>
<cfdump var="#getAllTableNames#" label="getAllTableNames" expand="false">
<!--- show one record from each table, provide insight into its structure --->
<cfloop query="getAllTableNames">
<cfquery name="thisTable" datasource="#thisDatasource#">
SELECT TOP 1 * FROM #table_name#
</cfquery>
<cfdump var="#thisTable#" label="#table_name#" expand="true">
</cfloop>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment