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
 General SQL Server Forums
 New to SQL Server Programming
 filter condition
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sent_sara
Constraint Violating Yak Guru

India
366 Posts

Posted - 11/05/2013 :  17:16:18  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

USA
1673 Posts

Posted - 11/05/2013 :  18:34:03  Show Profile  Reply with Quote
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

India
366 Posts

Posted - 11/05/2013 :  21:48:55  Show Profile  Reply with Quote
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

India
252 Posts

Posted - 11/11/2013 :  07:59:34  Show Profile  Reply with Quote
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
  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.03 seconds. Powered By: Snitz Forums 2000