0

I Have a table where I am trying to insert multiple rows into a single column... Any easy way of doing this ?

insert into tableA
(name) values(
'A',
'B',
'C',
.,
.,

I have about 400 rows I am getting the names from a excel sheet I tried using import from excel but that didn't work as it was throwing an error saying the format is wrong.

Any kind of ideas appreciated Thanks.

Alice
  • 17
  • 6

1 Answers1

2

Yes (assuming you are on SQL Server 2008 or newer and don't have more than 1000 columns per row).

You can insert rows with the same schema by separating the value blocks with commas.

INSERT INTO tableA (name)
VALUES ('A'), ('B'), ('C')...

The way you're currently doing it is attempting to add each row as a column.

D M
  • 5,769
  • 4
  • 12
  • 27