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;
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;
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;
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 ]
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us