SQL Server: copy, replace and paste within same table -


i pretty new sql , hope can me following general question.

i have large table several columns want 3 things via 1 stored procedure:

  1. select data country great britain (gb), e.g. using following:

    select *   xyz_tabledata  (countrycode 'gb') 
  2. copy above temp table , replace 'gb' in column countrycode 'xx'.

  3. copy data temp table , insert above table (i.e. copied data showing xx instead of gb).

can me start here? many this.

do in 1 step, no temp table required:

insert mytable(field1,field2,field3,country)    select field1,field2,field3,'xx' country mytable country='gb' 

this assumes trying append new set of records table, not update pre-existing records. read question 1 way, theresa read another...guess need decide meant.


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -