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:
select data country great britain (gb), e.g. using following:
select * xyz_tabledata (countrycode 'gb')
copy above temp table , replace 'gb' in column countrycode 'xx'.
- 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
Post a Comment