Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
tadin
Yak Posting Veteran
63 Posts |
Posted - 2007-03-19 : 17:20:20
|
| Create a Function call InitCap accepts 1 parameter of type varchar returns a varcharIt should only capitalize the first letter of the string passed to it.Items to watch out for. a-z not starting the string The 1st letter is already capitalizedThis problems deals with ASCII characters, just wanted to get some insight here. |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-03-19 : 17:31:42
|
| Run BOL = Books Online = Sql Server helplook up - Create Function - Like - Upper_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
|
tadin
Yak Posting Veteran
63 Posts |
Posted - 2007-03-19 : 17:52:11
|
| CREATE function INITCAP (@inString varchar(200) )returns varchar(200)asBEGINDECLARE @i int, @c char(1),@output varchar(255)SET @output=LOWER(@inString)SET @i=2SET @output=stuff(@output,1,1,UPPER(SUBSTRING(@inString,1,1)))WHILE @i<=LEN(@inString) BEGIN SET @c=SUBSTRING(@inString,@i,1) IF (@c=' ') OR (@c=',') IF @i<LEN(@inString) BEGIN SET @i=@i+1 SET @output=stuff(@output,@i,1,UPPER(SUBSTRING(@inString,@i,1))) END SET @i=@i+1 ENDRETURN @outputEND--Function CallSELECT dbo.initcap(ascii('hello')) I was wondering how to put the ascii with the function? Can anyone give me some feed back it would gratefull. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-19 : 17:56:30
|
| There already is a InitCap function here at SQLTeam.Please search.Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|
|
|
|