Microsoft SQL Server Links

Links, articles, scripts, tips, and other technical sources for managing SQL Server. DBALinks is dedicated to SQL Server and database administration.

CHECK OUR BLOGS!

 

 
BLOGS Minimize
Print  
 
SEARCH BLOGS Minimize

Print  
 
DOWNLOADS... Minimize
Print  
 
BOOKS... Minimize

Print  
 
Advertisement Minimize

 

Print  
 
Capitalize the first letter of every word in a text string or column - SQL Server
capitalizes the first letter of every word in a given text string

http://www.devx.com/tips/Tip/17608

create function initcap (@text varchar(4000))
returns varchar(4000)
as

begin
declare @counter int,
@length int,
@char char(1),
@textnew varchar(4000)

set @text = rtrim(@text)
set @text = lower(@text)
set @length = len(@text)
set @counter = 1

set @text = upper(left(@text, 1) ) + right(@text, @length - 1)

while @counter <> @length --+ 1
begin
select @char = substring(@text, @counter, 1)

IF @char = space(1)  or @char =  '_' or @char = ','  or @char = '.' or @char = '\'
or @char = '/' or @char = '(' or @char = ')'
begin
set @textnew = left(@text, @counter)  + upper(substring(@text,
@counter+1, 1)) + right(@text, (@length - @counter) - 1)
set @text = @textnew
end

set @counter = @counter + 1
end

return @text
end

Permalink |  Trackback
Location: BlogsAleksandar Tosic's Blog    
Posted by: Aleksandar Tosic Wednesday, October 15, 2008

Your name:
Title:
Comment:
Add Comment   Cancel 
 
Announcements Minimize
SQL Server Service Pack Versions - Thursday, October 30, 2008
Version @@VERSION MsDtsSrvr.exe File Version Registry Version Registry Patch Level
Release to Manufacturing 9.00.1399.00 9.0.1399.0 9.0.1399.06 9.0.1399.06
Service Pack 1 9.00.2047.00 9.0.2047.0 9.1.2047.00 9.1.2047.00
Post SP1 Cumulative Hotfix 9.0.2153.00 9.0.2153.0 9.1.2047.00 9.1.2153
Service Pack 2 CTP 9.00.3027.00 9.0.3027.0 9.2.3027.00 9.2.3027.00
Service Pack 2 9.00.3042.00 9.0.3042.0 9.2.3042.00 9.2.3042
Service Pack 2 Rollup 3 9.00.3186.0 9.00.3186.00 9.2.3042.00 9.2.3186
 

Print