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
 General SQL Server Forums
 New to SQL Server Programming
 String Subtraction

Author  Topic 

jess1984
Starting Member

14 Posts

Posted - 2010-06-30 : 09:03:08
hello,
I have variable type vachar(50) PBL109/10-11. I have to take PBL109 with sql query... pls help

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2010-06-30 : 09:20:04
What is the logic for geting PBL109 from PBL109/10-11.
1. do u want to get 6 character from starting
2. you want string before character /
or any thing else.

Vaibhav T

To walk FAST walk ALONE
To walk FAR walk TOGETHER
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2010-06-30 : 09:28:06
Assuming that your value starts in position 1, and
Assuming that it is always delimited by '/', and
Assuming there can not be another '/' in the text

DECLARE @v varchar(8000)
SET @v = 'PBL109/10-11'
SELECT SUBSTRING(@v,1,CHARINDEX('/',@v)-1)



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -