Sunday, December 5, 2010

Insert multiple rows values in one Insert statement (SQL 2008)

One of the nice tricks of insert statement; that it is possible to insert multiple rows values in one insert statement; you don’t need to insert each row in a separate statement.

CREATE TABLE DemoTable
    (
      ItemID INT IDENTITY
                 PRIMARY KEY,
      FirstName VARCHAR(50),
      LastName VARCHAR(50),
      CountryCode VARCHAR(4),
    )

INSERT  [DemoTable]
        (
          [FirstName],
          [LastName],
          [CountryCode]
        )
VALUES  ('Mahmoud','Hakeem','EG'),
        ('Michel','Durian','DE'),       
        ('Thomaz','Miracle','Fr')
 

No comments:

Post a Comment