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?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Pawan KumarConnect With a Mentor Database 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
Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

 
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
All Courses

From novice to tech pro — start learning today.