Solved

REPLACE DATA WITH SQL SCRIPT

Posted on 2008-10-16
4
297 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
  • 2
  • 2
4 Comments
 
LVL 60

Expert Comment

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

Author Comment

by:nursecore
Comment Utility
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
Comment Utility
update t
set field2 = left(field3,9)
from table t
where field1 = 'BOT'
0
 

Author Comment

by:nursecore
Comment Utility
This worked great!  Thanks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

728 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now