Click here to Skip to main content
15,040,743 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
plzzzzzzzz help me out........
Posted

The INSERT command allows multiple values and multiple rows:
SQL
INSERT INTO table_name (column1, column2, ...) 
VALUES (value1, value2, ...) 
       (nextvalue1, nextvalue2, ...)
   
Comments
Maciej Los 19-Mar-14 17:55pm
   
Note: missing a [,] between (... value2,...) and (nextvalue1...)

It doesn't work with SQL Server 2005 (a 4!).
Please, see solution1 by OriginalGriff and my comment to His answer.

I'd suggest to use something like this:
SQL
INSERT INTO TableName (TextField1, NumericField2, ..., FieldN)
SELECT TextField1, NumericField2, ..., FieldN
    FROM (
    SELECT 'SomeText' AS TextField1, 123 AS NumericField2, ..., FieldN
    UNION ALL
    SELECT 'SomeOtherText' AS TextField1, 456 AS NumericField2, ..., FieldN
    UNION ALL
    SELECT 'AnotherText' AS TextField1, 789 AS NumericField2, ..., FieldN
) AS Src


For further information, please see:
INSERT (sql)[^]
INSERT EXAMPLES (sql)[^]
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900