A simple script to decapitalize Column names

select 'exec sp_rename '+CHAR(39)+TABLE_NAME+'.'+ COLUMN_NAME +CHAR(39)+','+CHAR(39)+ 
	
	REPLACE(COLUMN_NAME , RIGHT(COLUMN_NAME, LEN(COLUMN_NAME)-1), LOWER( RIGHT(COLUMN_NAME, LEN(COLUMN_NAME)-1))) +CHAR(39)+', ''COLUMN'''
	
from INFORMATION_SCHEMA.COLUMNS

The above script can take column names for all tables in the database and provide the rename script to only capitalize the first letter.

Leave a Reply