Insert into one table from another table SQL

Monday, 22 June 2009 18:00 by myro

Just a quick note to myself. I can never seem to find an example of this when I need it.
This insert statement copies records from TABLE_2 to TABLE_1 with some custom values

INSERT INTO TABLE_1 (Prd_ID, Sta_ID, StS_ID, TiP_ID, Prd_Titolo, Prd_Descrizione, Prd_ID_Catalogo, Prd_Notifica)
SELECT (SELECT max(Prd_ID) from INTO TABLE_1)+1, 1, 1, 17,  [INTO TABLE_2].Descrizione,  [INTO TABLE_2].Descrizione,  [INTO TABLE_2].Codice, 'N'
FROM [INTO TABLE_2]
WHERE  ([INTO TABLE_2].ID = 3)

hope this post can refresh your mind too...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   Developer Life
Actions:   Bookmark and Share | Permalink | Comments (1) | Comment RSSRSS comment feed
If you consider this post usefull for your purposes, please consider visiting my sponsors to help me out with the myrocode.com maintenance. Thank you.

Comments