Solved

REPLACE DATA WITH SQL SCRIPT

Posted on 2008-10-16
4
334 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
New and Previous Values in a Query 7 36
Stored Proc - Rewrite 42 73
Finding Where Clause Value in SQL Views and SP 21 42
SQL question - help with insert for missing info 5 21
'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

726 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