Insert multiple rows into single column
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 am trying
INSERT INTO Data ( Col1 ) VALUES
('Hello', 'World')
That code was taken from this question, but it, like many other examples I have found on the web uses 2 columns, I just want to use 1. What am I doing wrong?
Thanks
另一种做法是与工会联系:
INSERT INTO Data ( Col1 )
select 'hello'
union
select 'world'
插入其他列的特定列的值保持不变: -
INSERT INTO `table_name`(col1,col2,col3)
VALUES (1,'val1',0),(1,'val2',0),(1,'val3',0)
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');
链接地址: http://www.djcxy.com/p/94504.html
上一篇: 使用SQL Server 2012将多行插入到临时表中
下一篇: 将多行插入单列