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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 select string
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

126 Posts

Posted - 11/04/2013 :  16:12:06  Show Profile  Reply with Quote
I need select two strings
for ex: transformer,toronto
I need string 1.before ','
2. after ','

first string I got it:select SUBSTRING(Vendor_Address3,0,CHARINDEX(',',Vendor_Address3,0)),but second I dont know
p.s:in second sometimes have space before word,how I can do it?

James K
Flowing Fount of Yak Knowledge

3873 Posts

Posted - 11/04/2013 :  16:30:54  Show Profile  Reply with Quote
Use LTRIM and/or RTRIM to remove leading and trailing spaces. Like shown below:
SELECT LTRIM(RTRIM(LEFT(Vendor_Address3,CHARINDEX(',',Vendor_Address3+',')-1))),
Go to Top of Page

Posting Yak Master

126 Posts

Posted - 11/05/2013 :  08:39:58  Show Profile  Reply with Quote
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000