Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Uploading comma delimited data into a table with numerous fields 1

Status
Not open for further replies.

jermine

Programmer
Joined
Jun 15, 2001
Messages
59
Location
SG
Is there any way of doing this just by running a script??

Thanks in advance!
 
Which version sql server are you using?

Anyway, try looking up DTS (data trans service).

Specify source as text file and select the filename for your source.

Select SQL server for destination.

add a transform data task from your source to destination.

Click properties of the task.
select table and check mappings.

"Execute step" to run the transfer

note: once you set up the initial DTS, you do not need to do it again. All you do is change the data in your source csv file, ane run "execute step" to put the data in the database (just like running a script file).
 
Hi,

You can use bcp utitility adding Execute Process Task to DTS Package using a format file.


bcp Database..TableName in filename -ULogin -PPassword -SServerName -f format file

In format file, you need to inform comma delimiter.
 

With SQL 7 and 2000, you can use BULK INSERT in a script or procedure.

BULK INSERT DBName.dbo.TableName
FROM 'f:\pathname\filename.csv'
WITH (FIELDTERMINATOR = ',',
ROWTERMINATOR = ',\n')

You can get more details in SQL BOL.

Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top