Thursday, February 4, 2010

Update a table with data from another existing table

Update a table with data from another existing table:

UPDATE tableToBeUpdated
SET fldToBeUpdate = (SELECT tblSource.fldToUpdate FROM tblSource WHERE tblSource.idOrder = tableToBeUpdated.idOrder)
WHERE EXISTS (SELECT tblSource.fldToUpdate FROM tblSource WHERE tblSource.idOrder = tableToBeUpdated.idOrder)

Tuesday, January 26, 2010

Create a new table with same schema and data from an existing table

Create a new table with same schema and data from an existing table

SELECT * INTO NEWtABLEnAME FROM FROMtABLEnAME