LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   SQL substring matching a character (http://www.linuxquestions.org/questions/programming-9/sql-substring-matching-a-character-873630/)

ShaqDiesel 04-07-2011 01:36 PM

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.

ShaqDiesel 04-07-2011 02:20 PM

By the way, the string "My dog spot" may have parentheses too.

szboardstretcher 04-07-2011 02:53 PM

Code:

select left(COL, locate('\n', COL) - 1) from tbl;


All times are GMT -5. The time now is 11:45 AM.