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
Solved

REPLACE DATA WITH SQL SCRIPT

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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
awk and Pythagoras? 5 19
SQL Stored Proc - Performance Enhancement 15 54
MS SQL Server time between records 14 46
Requesting help with creating an SQL query with 2 tables 6 25
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

861 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