Reputation: 169
I have comma-separated values. I need a query to insert into SQL Server 2008 with different rows
Bedford, Bloomfield, Broad Top, Colerain, Cumberland Valley, East Providence, East St. Clair, Harrison, Hopewell, Juniata, Kimmel, King, Liberty, Lincoln, Londonderry, Mann, Monroe, Napier, Snake Spring, Southampton, South Woodbury, Union, West Providence, West St. Clair, Woodbury,Bedford, Coaldale, Everett, Hopewell, Hyndman, Manns Choice, New Paris, Pleasantville, Rainsburg, St. Clairsville, Saxton, Schellsburg, Woodbury,
Upvotes: 1
Views: 1375
Reputation: 754230
One way to do it:
-- create a table to load the city names into
CREATE TABLE CitiesBulkLoad (CityName VARCHAR(100))
-- load the file into that staging table
BULK INSERT CitiesBulkLoad
FROM 'd:\commacities.txt' -- replace with **YOUR** file name here!!
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = ','
)
GO
-- now you should have the entries in that staging table
SELECT * FROM CitiesBulkLoad
Upvotes: 1