how to remove spaces in column names

I use this method for EVERYTHING.. I learned this method from a book called ‘SQL Server 7.0 Secrets’

-Aaron


select 'exec sp_rename ' + char(39) + so.name + '.[' + sc.name + + ']' + CHAR(39)
+ ', ' + CHAR(39) + REPLACE(sc.name, ' ', '') + CHAR(39) + ', ' + CHAR(39) +
'COLUMN' + CHAR(39)
from syscolumns sc
inner join sysobjects so
on sc.id = so.id
where so.xtype = 'u'
and sc.name like '% %'

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.