Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding Field Name in Multi Tables 1

Status
Not open for further replies.

WurzelGummidge

Technical User
Mar 18, 2003
27
0
0
GB
Is there a statetment that finds a field name (ie SECCODEID) in all the tables across a SQL DB ?
 
Try this:

SELECT * from Information_Schema.Columns where COLUMN_NAME= 'SECCODEID'

Sunil
 
That is perfect - i may be pushing my luck here but, further to your answer, how would i construct a sql statement that did the following:

Where ANY table has the field SECCODEID = 'abc123'
update SECCODEID to equal 'xyz321'

 
Try this:

SELECT 'UPDATE [' + Table_name + '] SET SECCODEID = ''xyz13'' where city=''abc13'''
from Information_Schema.Columns where COLUMN_NAME= 'SECCODEID'


This select statement should give u the SQL to update in the o/p window in QA. Copy all the SQL's and run it in QA.

Hope this helps

Sunil
 
Thanks once again, simple, straightforward, works-first-time answers that we all hope for but much too often get over-complicated.

EXCELLENT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top