Insert rows from one table to another

WITH rates(Code, Rate, BaseCode, LastUpdate, [Auto], Source) 
 AS (SELECT crc.Code, crc.Rate, crc.BaseCode, crc.LastUpdate, crc.[Auto], crc.Source
  FROM CurrencyRateCurrent crc
  WHERE crc.AccountId = 7
  )

INSERT INTO [CurrencyRateCurrent] (Code, Rate, BaseCode, LastUpdate, [Auto], Source,AccountId)
SELECT Code, Rate, NULL, LastUpdate, [Auto], Source, 20 FROM rates

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s