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.
Author |
Topic |
cipriani1984
Constraint Violating Yak Guru
304 Posts |
Posted - 2010-09-30 : 06:15:50
|
Hi,I have the following field from a data source which is abit annoying I would like to strip it out.Field1 = 'sname / fname title'LEFT(Field1, ISNULL(NULLIF (CHARINDEX('/', Field1) - 1, - 1), LEN(Field1))) This returns the 'sname' for me, how would i strip out the 'fname' only and ignore the 'title'?Thanks |
|
rohitvishwakarma
Posting Yak Master
232 Posts |
Posted - 2010-09-30 : 06:53:09
|
[code]DECLARE @data VARCHAR(200)SET @data = 'sname / fname title'DECLARE @data_2 VARCHAR(100)SET @data_2 = SUBSTRING(@data,CHARINDEX('/',@data)+1 ,LEN(@data))SELECT RIGHT(LTRIM(@data_2),CHARINDEX(' ', LTRIM(@data_2)))[/code] |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-09-30 : 12:59:31
|
STUFF(Field1,1,ISNULL(NULLIF (CHARINDEX('/', Field1) + 1, 1), 0),'')------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|
|
|