Answers for "insert multiple rows in sql server query"

SQL
11

sql insert multiple rows from select

INSERT INTO my_table SELECT * FROM source_table;
INSERT INTO my_table (a, b, c) SELECT a, b, c FROM source_table;
INSERT INTO my_table (a, b, c) SELECT a, b, c FROM source_table s
	WHERE s.my_col >= 10;
Posted by: Guest on May-02-2021
1

how to insert multiple records at once in sql acess

INSERT INTO target_table ( column_name1, column_name2 )
SELECT column_name1, column_name2
FROM (SELECT tableNameColumn AS column_name1, tableNameColumn2 FROM tableName, tableName2
WHERE tableNameColumn = 3 AND tableNameColumn2 = 1 
UNION ALL
SELECT tableNameColumn AS column_name1, tableNameColumn2 FROM tableName, tableName2
WHERE tableNameColumn = 3 AND tableNameColumn2 = 1) AS TMP

example:
INSERT INTO ProgKnowledge ( UserID, ProgramID )
SELECT UserID, ProgramID
FROM (SELECT Users.ID AS UserID, Programs.ProgramID FROM Users, Programs
WHERE Programs.ProgramID = 3 AND Users.ID = 1
UNION ALL
SELECT Users.ID AS UserID, Programs.ProgramID FROM Users, Programs
WHERE Programs.ProgramID = 4 AND Users.ID = 1)  AS add;
Posted by: Guest on September-24-2020
0

how to insert multiple rows in ssms

-- External tool only syntax  

INSERT   
{  
    [BULK]  
    { database_name.schema_name.table_or_view_name | schema_name.table_or_view_name | table_or_view_name }  
    ( <column_definition> )  
    [ WITH (  
        [ [ , ] CHECK_CONSTRAINTS ]  
        [ [ , ] FIRE_TRIGGERS ]  
        [ [ , ] KEEP_NULLS ]  
        [ [ , ] KILOBYTES_PER_BATCH = kilobytes_per_batch ]  
        [ [ , ] ROWS_PER_BATCH = rows_per_batch ]  
        [ [ , ] ORDER ( { column [ ASC | DESC ] } [ ,...n ] ) ]  
        [ [ , ] TABLOCK ]  
    ) ]  
}  
  
[; ] <column_definition> ::=  
 column_name <data_type>  
    [ COLLATE collation_name ]  
    [ NULL | NOT NULL ]  
  
<data type> ::=   
[ type_schema_name . ] type_name   
    [ ( precision [ , scale ] | max ]
Posted by: Guest on February-25-2021

Code answers related to "insert multiple rows in sql server query"

Code answers related to "SQL"

Browse Popular Code Answers by Language