SHARE
TWEET

Insert Data into SQL Table

a guest Feb 27th, 2012 13 Never
  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);
RAW Paste Data
Top