Please start any new threads on our new site at http://forums.sqlteam.com. 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
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 extract part of a text field
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

wided
Posting Yak Master

217 Posts

Posted - 01/30/2013 :  05:24:57  Show Profile  Reply with Quote
Hello

how to extract part of a text field as follows:

Field1 = '7589-05 '
or
Field1 = '10589-06 '

I would like to extract the data before (-):

7589 and 10589

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 01/30/2013 :  05:28:10  Show Profile  Reply with Quote
LEFT(Field1,CHARINDEX('-',Field1+'-')-1)

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Edited by - visakh16 on 01/30/2013 05:28:27
Go to Top of Page

wided
Posting Yak Master

217 Posts

Posted - 01/30/2013 :  06:19:45  Show Profile  Reply with Quote
thanks it is ok
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.05 seconds. Powered By: Snitz Forums 2000