This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Insert Data into SQL Table

By: a guest on Feb 27th, 2012  |  syntax: None  |  size: 0.51 KB  |  views: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ID ContactName1  Designation1 ContactName2 Designation2
  2. 1  A             dummy        B            sam
  3.        
  4. ID ContactName Designation
  5.        
  6. @ContactName1
  7. @Designation1
  8.  
  9. @ContactName2
  10. @Designation2
  11.        
  12. INSERT INTO DataTable (ContactName, Designation) VALUES
  13.     (@ContactName1, @Designation1),
  14.     (@ContactName2, @Designation2);
  15.        
  16. SELECT MAX(ID) AS max_id FROM DataTable
  17.        
  18. INSERT INTO Table(ID, ContactName, Designation)
  19.     VALUES(1, @ContactName1, @Designation1)
  20.     VALUES(1, @ContactName2, @Designation2);
clone this paste RAW Paste Data