MS SQL: Searching for / finding all table names where a certain MS SQL database field is used

Summary

Searching for / finding all table names where a certain MS SQL Sage 200 Evolution database field is used.

Description

This article explains how to search for all the table names where a certain MS SQL database field is used.

Resolution

Please note this article assumes you have a basic understanding of how to navigate within MS SQL Management Studio and how to run basic SQL queries. Therefore, please contact either your Evolution Business Partner (BP) or Evolution Support for further assistance if needed.

To explain further we’ll make use of the following scenario:

In this example we will be looking for all Sage Evolution database tables that include a field name called ‘last’ or anything similar.

The intention is to find all associated table names and the exact field name/s of your search field name = last

Therefore, run the SQL script below on your company database. Only change the key search word in the bottom line of the script below to last in this case.

Also note to enable the search, the SQL script is using the wild card search % symbols as can be seen below.

SELECT c.name AS ‘Fieldname’

,t.name AS ‘Tablename’

FROM sys.columns c

JOIN sys.tables t ON c.object_id = t.object_id

WHERE c.name LIKE ‘%last%’

When the SQL script is executed, the results below indicate all the tables where the search field name of last is found in, as well as the actual field name per table.

Image

Tags:

Categories:

Comments are closed