I have a Database, in which I need to clean the spaces of a specific field in all the tables of the database. This field is called delegate in your table and idDelegado in your foreign ones. For example, if the code for a delegate is ' DEL012 '
I need to do a Trim()
on all tables where there is a idDelegado
. To consult all the tables where I have a iDdelegado
I do it like this:
Select TABLE_NAME,COLUMN_NAME
from INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME = 'idDelegado' AND TABLE_NAME NOT like 'VIS_%'
ORDER BY COLUMN_NAME
And it occurs to me to go through the result of the query with a cursor and do the corresponding Trim(), but I doubt that this is the best solution. Is there a better way to do it?