Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

how to import

Posted on 2016-10-01
7
Medium Priority
?
79 Views
Last Modified: 2016-10-28
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.
0
Comment
Question by:shwelopo
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 14

Expert Comment

by:Nakul Vachhrajani
ID: 41824761
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
 
LVL 35

Accepted Solution

by:
Pawan Kumar earned 2000 total points
ID: 41824809
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
 
LVL 35

Expert Comment

by:Pawan Kumar
ID: 41826261
@Author - Can you send me the text file, I shall create a small script for you..
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 52

Expert Comment

by:Vitor Montalvão
ID: 41827665
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
 

Author Comment

by:shwelopo
ID: 41836822
thanks
0
 
LVL 52

Expert Comment

by:Vitor Montalvão
ID: 41857050
shwelopo, if your question has been answered please mark the comment or comments that helped you so this question can be closed.
0
 

Author Closing Comment

by:shwelopo
ID: 41863936
thank you
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question