Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 367
  • Last Modified:

REPLACE DATA WITH SQL SCRIPT

I have a data back that I need to mass copy data from one field to another.  This is a description field only and will not disrupt the function of the database.  I know what I want but don't know the scripting language.  What I need in lamans terms is as follows.

IF (FIELD1 = "BOT") THEN REPLACE (FIELD2) WITH (FIELD3)

Thanks
0
nursecore
Asked:
nursecore
  • 2
  • 2
1 Solution
 
chapmandewCommented:
update t
set field2 = field3
from table t
where field1 = 'BOT'
0
 
nursecoreAuthor Commented:
I tried this a got an error that says something to the effect that Field3 is longer than Field2.  The data that needs to be copied from Field3 is only the first 9 spaces.  Can you tell me how to change the script to handle this.
Thanks
0
 
chapmandewCommented:
update t
set field2 = left(field3,9)
from table t
where field1 = 'BOT'
0
 
nursecoreAuthor Commented:
This worked great!  Thanks
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now