473,770 Members | 2,153 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Converting Text to Proper Text in SQL

Given a string it should convert it to a proper text.
Example: if you passed a string 'Cat in the hat', I want 'Cat In The
Hat'

Curious about few things, Does sql have Instr OR Split(like VB)
functionality

Anybody can help??

Jul 23 '05 #1
3 2831
(m.******@gmail .com) writes:
Given a string it should convert it to a proper text.
Example: if you passed a string 'Cat in the hat', I want 'Cat In The
Hat'
I though "Cat in the Hat" was the proper title text in English,
and "Cat In The Hat" is what you get when you use a computer?

SQL Server is not strong on text maninpulation. You would have to loop
over the string, either one by one, or possibly piece by piece with
charindex(). There is no built-in for this.
Curious about few things, Does sql have Instr OR Split(like VB)
functionality


I would encourage you to look at Functions->String Functions in the
T-SQL References in Books Online. There you can learn about all functions
to manipulate strings in T-SQL.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #2


m.******@gmail. com wrote:
Given a string it should convert it to a proper text.
Example: if you passed a string 'Cat in the hat', I want 'Cat In The
Hat'

Curious about few things, Does sql have Instr OR Split(like VB)
functionality

Anybody can help??


CREATE function TitleCase
(
@my_str as varchar(8000)
)
Returns varchar (8000)
AS
Begin
Declare @this_str as varchar(8000)
Declare @word_str as varchar(5000)
Declare @spc int
Declare @patindx1 as varchar(100)
Declare @patindx2 as varchar(100)
Declare @patindx3 as varchar(100)
Declare @patindx4 as varchar(100)
select @patindx1 = '%[ -"/().]%'
select @patindx2 = '%[''][^s]%'
select @patindx4 = '%[''][s][a-z]%'
select @patindx3 = '%[0123456789][^snrt][^tdh]%'
Select @this_str = ''

Select
@my_str = LTrim(RTrim(@my _str))
While Len(@my_str) > 0
Begin
if (PatIndex(@pati ndx1, @my_str) + PatIndex(@patin dx2, @my_str) +
PatIndex(@patin dx3, @my_str) + PatIndex(@patin dx4, @my_str) = 0)
Begin
Select
@spc = Len(@my_str)
End
Else
Begin
Select @spc = PatIndex(@patin dx1, @my_str)
If @spc = 0 Or (PatIndex(@pati ndx2, @my_str) < @spc
And PatIndex(@patin dx2, @my_str) > 0)
Select @spc = PatIndex(@patin dx2, @my_str)
If @spc = 0 Or (PatIndex(@pati ndx3, @my_str) < @spc
And PatIndex(@patin dx3, @my_str) > 0)
Select @spc = PatIndex(@patin dx3, @my_str)
If @spc = 0 Or (PatIndex(@pati ndx4, @my_str) < @spc
And PatIndex(@patin dx4, @my_str) > 0)
Select @spc = PatIndex(@patin dx4, @my_str)

End

Select
@word_str = Left(@my_str, @spc)

Select
@this_str = @this_str + Upper(Left(@wor d_str,1)) +
Lower(SubString (@word_str,2,@s pc))
select @my_str = Right(@my_str, (Len(@my_str)-(@spc)))
End
Return (@this_str)
End

--
David Rowland
NEW DBMonitor Out Now! New Email Alert Feature!
http://dbmonitor.tripod.com

Jul 23 '05 #3
Great, I was about to create one, appreciate your time.

Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
16470
by: Joseph Suprenant | last post by:
I have an array of unsigned chars and i would like them converted to an array of ints. What is the best way to do this? Using RedHat 7.3 on an Intel Pentium 4 machine. Having trouble here, hope someone can help Thanks
20
7356
by: Al Moritz | last post by:
Hi all, I was always told that the conversion of Word files to HTML as done by Word itself sucks - you get a lot of unnecessary code that can influence the design on web browsers other than Internet Explorer. Our computer expert in my company had told me already a while ago that I should learn HTML and encode myself. I was never inclined to do so (I am no computer expert), and when upon his suggestion I looked how my pages (converted to...
2
1786
by: | last post by:
Hi all, I'm here to humbly request some "gimme" help from the group. I discovered the infinite wonders of VS.NET 2005 and ASP.NET 2.0 at Tech Ed a couple of weeks ago, and since returning to work I haven't looked back. Unfortunately I still have some critical functions that I originally created as vbscript functions. I need these functions to do my work. Before I can transition entirely to C#-based ASP.NET sites, I need these functions...
7
1631
by: djc | last post by:
I have typically always used one of the VB CType functions (not CType itself but CInt, CString, etc...) to cast/convert an input value to its proper type before passing it as a parameter to a SQL stored procedure. I recently came accross one I did not know how to handle though... TinyInt. I have an SQL field of type TinyInt which is an 8bit integer. I came accross a ToInt16() vb function but not one for an 8 bit 'TinyInt'. So I next just...
2
1548
by: iwdu15 | last post by:
ok, now i had a similar question involving changing colors from GDI to web, and i couldnt find a font translator class so here i am. I am trying to change rtf to html (w/o 3rd party extensions, since i only need to convert text) and when i attemp to get the font size from a rich text box and show it in a WebBrowser control, the size is way too big. how can i get the font size rite? if tried Me.rtbText.Font.Size and
116
35978
by: Dilip | last post by:
Recently in our code, I ran into a situation where were stuffing a float inside a double. The precision was extended automatically because of that. To make a long story short, this caused problems elsewhere in another part of the system where that figure was used for some calculation and some eventual truncation led to the system going haywire. So my question is, given this code: int main() { float f = 59.89F;
10
1997
by: Ron | last post by:
I want to calculate the surface area of a sphere from an inputed radius with option strict on. I guess I am not converting something correctly. Here is what I am doing: I have a textbox txtradius that I enter a radius into. I then have a lable that I want the surface area to be displayed in called lblsurface
0
5454
by: Alci | last post by:
I am getting some Korean characters data from MS SQL server. These data were submitted as UTF-8 into the database, but stored as normal varchars. So, when I getting them out of database by using Gridview +SqlDataSource, they are actually ASCII format, but I couldn't just convert the encoding of the page to get the proper UTF-8 format Korean texts. So, i modified a function from MS site, try to convert ASCII to UTF-8, as below protected...
3
3613
by: Jone | last post by:
Hello, I have tried to convert a Mac text file to Windows using code below. Encoding Win = Encoding.GetEncoding("Windows-1252"); Encoding Mac = Encoding.GetEncoding("macintosh"); byte macBytes = Mac.GetBytes(Row);
0
9591
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10228
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10057
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10002
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8883
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6676
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3970
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3575
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.