473,418 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

hot to insert cvs file in sql

11
hi
i m trying to insert .csv file in ms sqlserver but its not working


my cvs file data formate below is


Expand|Select|Wrap|Line Numbers
  1. "12.204.8.120","12.204.8.151","214698104","214698135","VI","Virgin Islands, U.S."
  2. "12.204.8.152","12.204.8.159","214698136","214698143","PR","Puerto 
  3.  
  4. Rico"
  5. "12.204.8.160","12.204.8.175","214698144","214698159","VI","Virgin Islands, U.S."
  6. "12.204.8.176","12.204.8.183","214698160","214698167","PR","Puerto Rico"
  7. "12.204.8.184","12.204.8.191","214698168","214698175","VI","Virgin Islands, 
  8.  
  9. U.S."
  10. "12.204.8.192","12.204.8.255","214698176","214698239","PR","Puerto Rico"
  11. "12.204.9.0","12.204.9.79","214698240","214698319","VI","Virgin 
  12.  
  13. Islands, U.S."
  14. "12.204.9.80","12.204.9.127","214698320","214698367","PR","Puerto Rico"
  15. "12.204.9.128","12.204.9.135","214698368","214698375","VI","Virgin Islands, U.S."
  16. "12.204.9.136","12.204.9.143","214698376","214698383","US","United 
  17.  
  18. States"
  19. "12.204.9.144","12.204.10.143","214698384","214698639","PR","Puerto Rico"
  20. "12.204.10.144","12.204.10.159","214698640","214698655","VI","Virgin 
  21.  
  22. Islands, U.S."
  23. "12.204.10.160","12.204.12.223","214698656","214699231","PR","Puerto Rico"
i m using this code


Expand|Select|Wrap|Line Numbers
  1. use DBGMTEST
  2. Go
  3.  Create table csvtest
  4. ( begin_addr char(50) not null,
  5. end_addr char(50) not null,
  6. begin_num varchar(50) not null,
  7. end_num varchar(50) not null,
  8. code char(20) not null,
  9. country varchar(max) not null,
  10. )
  11. Go
  12. Bulk Insert csvtest
  13. from 'C:\GM\GeoIP.csv'
  14. with
  15. (
  16.  
  17. Fieldterminator = '","',
  18. ROWTERMINATOR = '\r\n'
  19. )
  20. Go
  21. select * from csvtest
  22. Go
  23. Drop table csvtest
  24.  
  25. Go
this code works not giviing any error but the quatation marks "" does't remove and ROWTERMINATOR does't work.


its show all data of csv file in one row.the last field (country) of my table shows all data

pls help me
May 17 '10 #1
1 2355
ck9663
2,878 Expert 2GB
Use a format file.Here, read this...

Happy Coding!!!

~~ CK
May 17 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Ragnorack67 | last post by:
Hi, I need some advice on what to do. I have this MySQL insert file, with about 30,000 records. One of the datafields has names in it. When this list was put together, apparently there was extra...
1
by: Chris Petersen | last post by:
Is there a better/simpler way than this? use POSIX ('strftime'); my $dateCreated = strftime "%b %d, %Y %H:%M", localtime ((stat("c:\\test.txt"))); How would I go about displaying the output...
4
by: Rob | last post by:
Hey, I'm pretty new to MySQL and have a question. I've built a database locally and have inputed some information. I need to go back and update some records, specifically by taking long pieces...
5
by: TThai | last post by:
HI, I'm trying to insert records to a table using bcp command. The problem is the input file to the bcp is a text file that looks like this: Text file data: 1234 abc def ghi jkl mno ...
6
by: pk | last post by:
Sorry for the piece-by-piece nature of this post, I moved it from a dormant group to this one and it was 3 separate posts in the other group. Anyway... I'm trying to bulk insert a text file of...
7
by: tano | last post by:
Hello, I have to insert a char in the middle of a string, I have written two functions but I don't know what is the better? The problem is: if I use malloc() I copy all the string with the new...
1
by: Tom | last post by:
Hi, I have a vb.net program from wich i want to open a ms word-doc and insert an other document into it. But i want it to work on every version of word (minimum word 2000). can anyone help...
1
by: KELVIN TRAN | last post by:
There are anyway to insert a picture or MS Word file in this text box (Make easy for question or discussion)? Thank you very much for your help. Best regards, Kelvin Tran *** Sent via...
0
by: DeepthiSem | last post by:
Hi Everyone I have an issue while saving .rpt file into DB2 database using C# windows application. The provider i have used is OLEDB provider. It is not supporting to insert large amount of data...
0
by: alivip | last post by:
I write code to get most frequent words in the file I won't to implement bigram probability by modifying the code to do the following: How can I get every Token (word) and ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.