create procedure gmi_columns_name_lower
as
begin
	declare @sqlcommand nvarchar(max);

	DECLARE var_cursor CURSOR FOR
		select ('EXEC sp_rename ''' + TABLE_NAME +'.'+ COLUMN_NAME +''', ''' + LOWER(COLUMN_NAME) +''', ''COLUMN''') sqlcommand
		FROM INFORMATION_SCHEMA.COLUMNS
		where TABLE_NAME not in ('dtproperties','sysdiagrams')
		order by table_name
	FOR READ ONLY

	OPEN var_cursor
	FETCH NEXT FROM var_cursor INTO 
		@sqlcommand

	WHILE @@FETCH_STATUS = 0
	BEGIN
		exec sp_executesql @sqlcommand;

		FETCH NEXT FROM var_cursor INTO 
			@sqlcommand
	END

	CLOSE var_cursor
	DEALLOCATE var_cursor;
end 
