Solved

REPLACE DATA WITH SQL SCRIPT

Posted on 2008-10-16
4
347 Views
Last Modified: 2012-06-21
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
Comment
Question by:nursecore
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 60

Expert Comment

by:chapmandew
ID: 22733262
update t
set field2 = field3
from table t
where field1 = 'BOT'
0
 

Author Comment

by:nursecore
ID: 22733419
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
 
LVL 60

Accepted Solution

by:
chapmandew earned 500 total points
ID: 22733497
update t
set field2 = left(field3,9)
from table t
where field1 = 'BOT'
0
 

Author Comment

by:nursecore
ID: 22745000
This worked great!  Thanks
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question