SQL Server Forums
Profile | Register | 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
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

wided
Posting Yak Master

201 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
52325 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

201 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  
 New 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.14 seconds. Powered By: Snitz Forums 2000