0
Hello,
I need to check all tables that contain the same column and make a logic to change all values of all these columns.
I’m trying to get the name of the tables as follows:
DECLARE @TABELA VARCHAR(255)
SELECT @TABELA = MIN ( TABLE_NAME ) FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'COD_COLUM'
print @TABELA
WHILE @TABELA IS NOT NULL
BEGIN
Select COD_COLUM from @Tabela
SELECT @TABELA = MIN ( TABLE_NAME ) FROM INFORMATION_SCHEMA.COLUMNS where TABLE_NAME > @TABELA and
COLUMN_NAME = 'COD_COLUM'
END
When I try to do that, I have the following mistake: Must declare the table variable "@TABLE".
I can’t think of any other way to do it, someone has some solution?