I\'m new to SQL, (using SQL 2008 R2) and I am having trouble inserting multiple rows into a single column.
I have a table named Data
and this is what I
INSERT INTO Data ( Col1 ) VALUES ('Hello'), ('World')
Another way to do this is with union:
INSERT INTO Data ( Col1 )
select 'hello'
union
select 'world'
To insert into only one column, use only one piece of data:
INSERT INTO Data ( Col1 ) VALUES
('Hello World');
Alternatively, to insert multiple records, separate the inserts:
INSERT INTO Data ( Col1 ) VALUES
('Hello'),
('World');
If your DBMS supports the notation, you need a separate set of parentheses for each row:
INSERT INTO Data(Col1) VALUES ('Hello'), ('World');
The cross-referenced question shows examples for inserting into two columns.
Alternatively, every SQL DBMS supports the notation using separate statements, one for each row to be inserted:
INSERT INTO Data (Col1) VALUES ('Hello');
INSERT INTO Data (Col1) VALUES ('World');
INSERT INTO hr.employees (location_id) VALUE (1000) WHERE first_name LIKE '%D%';
let me know if there is any problem in this statement.
In that code you are inserting two column value. You can try this
INSERT INTO Data ( Col1 ) VALUES ('Hello'),
INSERT INTO Data ( Col1 ) VALUES ('World')