SQL Script to Return Specific Columns within a Database
Posted Friday, January 15th, 2010 by Amy Walsh
This post was submitted by Christina Belding who is a Managing Consultant here at I.B.I.S., Inc. She provides a real-life scenario of what many of us come across out in the field and a very useful script to locate specific columns in a database.
Christina’s story…I had to find every table where a specific field was being stored quickly. My client needed to make a decision on whether or not they should change some core behavior or locate another field to be used, however, we weren’t sure how widespread our field truly was. Did it have a history table associated with it? Were there a lot of transactional tables? Hmmmm….
We ran the following script (change the CALLNBR field to whatever the physical name of the field is you’re looking for) and voila! We determined in GP10, the CALLNBR (call number field in field service) was being referenced in 54 tables.
select
on sysobjects.id = syscolumns.id
where syscolumns.name like ‘CALLNBR’
order by 1
from syscolumns
You can then go into the resource descriptions within GP and get more information on the specific tables listed.
