November 16, 2005 at 3:41 am
Hi friends,
I have a problem selecting or finding from a database. It is given as below:
I have a name column (varchar(20)) which contains John, Jojo, Johan, Mania etc.
Suppose I want to select all those names which contains substring, say "Jo".
And one more thing, how will I update all those columns containing "Jo" substrings with another substring; say "Lo"?
Please help me, i'm a beginner in MS SQL Server
Thanks in advance
Chhana
November 16, 2005 at 3:50 am
Take a look at REPLACE in BOL.
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
November 16, 2005 at 3:51 am
Ooh, and as for "How to SELECT", have a look at LIKE.
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
November 16, 2005 at 6:24 am
Just to illustrate Frank's methods..
declare @string varchar(50) set @string = 'Frank and John are back' if charindex('Jo', @string) > 1 print 'exists' else print 'not exists' /***********************/ select * from myTable where myCol like 'Jo%' /***********************/ update myTable set myCol = case when myCol like 'Jo%' then replace(myCol, 'Jo', 'Lo') else myCol end
**ASCII stupid question, get a stupid ANSI !!!**
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply