rename a column in all the tables - SQL

Viewed 2951

I need to rename a column in all tables in my database. so a column 'OldColumn' has to be renamed to 'NewColumn' in all the tables

I could get list of tables that has this column using this query:

SELECT TABLE_NAME 
FROM INFORMATION_SCHEMA.COLUMNS 
WHERE COLUMN_NAME= <Column Name>

But how can i rename it in all tables as simple as possible and don't have to write a cursor?

4 Answers
Related