Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Advanced String Select

Author  Topic 

lane0618
Posting Yak Master

134 Posts

Posted - 2003-02-18 : 21:14:49
I have the following records.

613501.prt.3
6x30.prt.3
761501.prt.1
761501.prt.unknown

I want to select only the text before the .prt% so I end up with:

613501
6x30
761501
761501

Is this possible?

Thanks in Advance!
Lane



robvolk
Most Valuable Yak

15732 Posts

Posted - 2003-02-18 : 21:18:54
SELECT Left(myCol, CharIndex('.prt', myCol)-1)
FROM myTable


...or...

SELECT Substring(myCol, 1, CharIndex('.prt', myCol)-1)
FROM myTable


Go to Top of Page
   

- Advertisement -