Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-07-2011, 01:36 PM   #1
Registered: Jul 2005
Posts: 144

Rep: Reputation: 15
SQL substring matching a character

I have the following string:
"My dog spot
(page 1)".
I want just "My dog spot". How do I do this in SQL Server? Thanks.

By the way, I don't know how long the string in the parentheses is going to be.
Old 04-07-2011, 02:20 PM   #2
Registered: Jul 2005
Posts: 144

Original Poster
Rep: Reputation: 15
By the way, the string "My dog spot" may have parentheses too.
Old 04-07-2011, 02:53 PM   #3
Senior Member
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,563
Blog Entries: 1

Rep: Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211
select left(COL, locate('\n', COL) - 1) from tbl;


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl only matching single-character regex patterns? Lordandmaker Programming 3 01-20-2009 08:59 AM
any character matching doesn't yield expected result in PERL gaynut Programming 4 09-26-2008 01:04 AM
Extract substring matching a regular expression tikit Linux - General 2 02-18-2008 01:47 PM
C++ problem extracting a substring - extra character Nylex Programming 4 07-22-2007 11:21 AM
Matching with SQL Ephracis Programming 4 12-16-2004 05:09 AM

All times are GMT -5. The time now is 11:04 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration