Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

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

tjf
Starting Member

2 Posts

Posted - 10/09/2012 :  17:05:05  Show Profile  Reply with Quote
I have the following issue that I am looking to solve via SQL.

A varchar contains the following:
Option 1 []
Option 2 []
Option 3 [x]
<variable text>

I would like to be able to change the lines with "Option" in them without knowing fully what the line contains. In this case I would not know that Option 1 & 2 where unchecked and Option 3 was. This means using a simple replace would not work. In pseudo code:

update Table
set VarChar
replace 'Option 1 *' with 'Option 1 [x]
replace 'Option 2 *' with 'Option 2 []
replace 'Option 3 *' with 'Option 3 []
keep rest of text unchanged

Any pointers appreciated. Thanks.

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 10/09/2012 :  21:21:25  Show Profile  Reply with Quote
sorry didnt get that. Are Option 1,Option 2 etc fields or value within a field?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

tjf
Starting Member

2 Posts

Posted - 10/16/2012 :  12:13:06  Show Profile  Reply with Quote
They are values within a field.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 10/16/2012 :  23:23:11  Show Profile  Reply with Quote
ok..do you've consistent format in which values are coming?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next 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.04 seconds. Powered By: Snitz Forums 2000