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 2005 Forums
 SSIS and Import/Export (2005)
 Derive Column Remove Characters to Left
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Brittney10
Posting Yak Master

USA
152 Posts

Posted - 05/16/2013 :  11:48:16  Show Profile  Reply with Quote
I need to create a derived column that removes the characters to the left of an asterisk.

Example:

5678*12345 would be 12345

Thanks for you help in advance!

James K
Flowing Fount of Yak Knowledge

3559 Posts

Posted - 05/16/2013 :  12:17:53  Show Profile  Reply with Quote
STUFF(col,1,CHARINDEX('*',col+'*'),'')
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 05/17/2013 :  00:10:57  Show Profile  Reply with Quote
SELECT PARSENAME(REPLACE(col,'*','.'),1)

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

James K
Flowing Fount of Yak Knowledge

3559 Posts

Posted - 05/17/2013 :  08:11:16  Show Profile  Reply with Quote
quote:
Originally posted by visakh16

SELECT PARSENAME(REPLACE(col,'*','.'),1)

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs


PARSENAME is less reliable than th emethod I posted. Both the examples shown below will return inocrrect results if you use parsename
SELECT PARSENAME(REPLACE('abc*x.yz','*','.'),1)
SELECT PARSENAME(REPLACE('abc[d*e]xyz','*','.'),1)
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.06 seconds. Powered By: Snitz Forums 2000