how to import

How do i import a text file into sql server 2008?  do I need to create the destination table first?  The record size is 2513.  there maybe 4500 records.  Thank you.
shwelopoAsked:
Who is Participating?
 
Pawan KumarDatabase ExpertCommented:
Try something like..

CREATE TABLE testCSV
(
	 Name NVARCHAR(1000)
	,Disponibilidade NVARCHAR(1000)
	,Data NVARCHAR(1000)
	,Report NVARCHAR(1000)
	,Country NVARCHAR(1000)
	,Last_refresh NVARCHAR(1000)
)
GO

BULK
INSERT testCSV
FROM 'E:\Pawan1.CSV'
WITH
(
FIELDTERMINATOR = ';',
ROWTERMINATOR = '|'
)
GO

SELECT * FROM testCSV

Open in new window

0
 
Nakul VachhrajaniTechnical Architect, Capgemini IndiaCommented:
I would start by determining whether this is a one-time activity or a repeating one?

If it's a one-time activity, I would suggest using the Import & Export Data Utility wizard (Start -> All Programs -> Microsoft SQL Server -> Import and Export Data Utility) to import the data.

If it's a repeating activity, the ideal choice would be to create a SSIS package or use the BCP/Bulk insert strategy.

In both cases, my recommendation would be to create the destination table beforehand since that would give you the maximum control on the table design.
0
 
Pawan KumarDatabase ExpertCommented:
@Author - Can you send me the text file, I shall create a small script for you..
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Vitor MontalvãoMSSQL Senior EngineerCommented:
What's the goal of this operation?
Nakul's comment is very good. It will be also good if you could give some feedback.
0
 
shwelopoAuthor Commented:
thanks
0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
shwelopo, if your question has been answered please mark the comment or comments that helped you so this question can be closed.
0
 
shwelopoAuthor Commented:
thank you
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.