"Capitalize" an entire SQL Server database

It is common practice to keep string capitalized in database. First advantage will be avoiding possible problems which might appear in case of comparing strings.

The next code snippet will generate a script which capitalize all varchar columns in your database. I kindly recommend you to backup database before running this script. I didn’t test it the behavior in case of database contains trigger for update.

SET NO COUNT ON

DECLARE Cur cursor for select name, id from sysobjects where xtype = 'u'
DECLARE @name varchar (255)
DECLARE @id int
DECLARE @Str varchar (8000)

Open Cur
fetch next from Cur into @name, @id

WHILE @@Fetch_Status = 0
BEGIN
    Set @Str = ' Update ' + @name + ' set '
    Update Syscolumns
    set @str = @Str + name + ' = UPPER ( ' + name + ' ) ,'
    where id = @id and xtype in (175, 239, 99, 231, 35, 167)

    set @Str = left (@Str, Len(@Str) - 1)
    PRINT @Str

    fetch next from Cur into @name, @id
END

CLOSE Cur
DEALLOCATE Cur

Is this useful?