![]() |
|
String içindeki kelimelerin baş harflerini büyük harfe çevirme - Baskı Önizleme +- Delphi Can (https://www.delphican.com) +-- Forum: Veri Tabanı (https://www.delphican.com/forumdisplay.php?fid=4) +--- Forum: MS SQL Server (https://www.delphican.com/forumdisplay.php?fid=103) +--- Konu Başlığı: String içindeki kelimelerin baş harflerini büyük harfe çevirme (/showthread.php?tid=1716) |
String içindeki kelimelerin baş harflerini büyük harfe çevirme - adelphiforumz - 22-12-2017 Selamlar String içindeki kelimerin baş harflerini büyük harf yapmak için böyle bir script buldum. Belki lazım olur. Daha kısa yolu varsa paylaşırsanız memnun olurum [Ars=sql] Create Function [dbo].[FNsv_KelimeBasHarfleriniBuyult] (@string Varchar(1024) ) Returns Varchar(1024) As Begin Declare @Index Int, @ResultString Varchar(1024) Set @Index = 1 Set @ResultString = '' While (@Index <LEN(@string)+1) Begin If (@Index = 1) Begin SET @ResultString = @ResultString + Upper(Substring(@string, @Index, 1)) SET @Index = @Index+ 1 End Else If ((Substring(@string, @Index-1, 1) =' 'or Substring(@string, @Index-1, 1) ='-' or Substring(@string, @Index+1, 1) ='-') and @Index+1 <> Len(@string)) Begin Set @ResultString = @ResultString + Upper(Substring(@string,@Index, 1)) Set @Index = @Index +1 End Else Begin Set @ResultString = @ResultString + LOWER(SUBSTRING(@string,@Index, 1)) Set @Index = @Index +1 End End If (@@ERROR <> 0) Begin Set @ResultString = @string End Return @ResultString End [/ars] |