Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching for multiple carriage returns in a text field

Status
Not open for further replies.

ColinGregory

Technical User
Feb 16, 2001
39
US
Hi Everyone,

I have a text type field which may contain one or more carriage returns. Is there a way to search the field and only select those records which contain two or more carriage returns?

I've trawled the archive and BOL with no luck. Any pointers much appreciated.

Many thanks
Colin
 
I think this works....

Code:
select * from mytable where patindex('%' + char(13) + '%' + char(13) + '%' ,mytextfield) > 0
 
Only pointers I can give, and you may already know this, are that it will probably involve a patindex of a patindex to return where, if present, the second carriage return occurs
So say where not 0
Also, carriage return is generally either char(13) or '\n'
Have a look at char and patindex

Damian.
 
Totally spot on.

Thanks for the speedy replies lads.

Colin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top