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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 filter condition

Author  Topic 

sent_sara
Constraint Violating Yak Guru

377 Posts

Posted - 2013-11-05 : 17:16:18
Hi,

can i know how to display in select statment starting from the word 'basic'

table name:version

table values:

versionid Versiondescription
53666445 SAG Basic Guild Agreement 07/01/2014 - 12/31/2014 PT - HV
53666446 SAG Basic Guild Agreement 07/01/2014 - 12/31/2014 HV - HV
53666447 SAG Basic Guild Agreement 07/01/2014 - 12/31/2014 NWLN- SY
53666448 SAG Basic Guild Agreement 07/01/2014 - 12/31/2014 BC - SY


output should be:
versiondescription
Basic Guild Agreement 07/01/2014 - 12/31/2014 PT - HV
Basic Guild Agreement 07/01/2014 - 12/31/2014 HV - HV
Basic Guild Agreement 07/01/2014 - 12/31/2014 NWLN- SY
Basic Guild Agreement 07/01/2014 - 12/31/2014 BC - SY

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2013-11-05 : 18:34:03
Try using CHARINDEX to find the offset of your keyword "Basic" and SUBSTRING to extract the desired results. Details on both functions are in Books Online.
HTH

=================================================
No, no, you're not thinking, you're just being logical. -Niels Bohr
Go to Top of Page

sent_sara
Constraint Violating Yak Guru

377 Posts

Posted - 2013-11-05 : 21:48:55
Thanks got the result
quote:
Originally posted by Bustaz Kool

Try using CHARINDEX to find the offset of your keyword "Basic" and SUBSTRING to extract the desired results. Details on both functions are in Books Online.
HTH

=================================================
No, no, you're not thinking, you're just being logical. -Niels Bohr


Go to Top of Page

mohan123
Constraint Violating Yak Guru

252 Posts

Posted - 2013-11-11 : 07:59:34
declare @vc_name VARCHAR(MAX)
set @vc_name = 'SAG Basic Guild Agreement 07/01/2014 - 12/31/2014 PT - HV'
select SUBSTRING(@vc_name,CHARINDEX(' ',@vc_name)+1,LEN(@vc_name))

P.V.P.MOhan
Go to Top of Page
   

- Advertisement -