How To Insert Data From A Select


Have you ever wanted to insert data by selecting values from a table?


Consider we have a table called XMLData, and it has a column called Id, Type, RawData


INSERT INTO XMLData (RawType, RawData)
SELECT 'Client', RawData FROM XMLData WHERE RawType = 'Customer'



The example above will copy records flagged as RawType = 'Customer', and insert them as new records, changing the RawType to 'Client'