473,748 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

hot to insert cvs file in sql

11 New Member
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 2363
ck9663
2,878 Recognized Expert Specialist
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
1931
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 space formatting inserted at the end of each name. I want to remove these, so for example: INSERT INTO `table_one` VALUES ('John Doe ', 1); INSERT INTO `table_one` VALUES ('Jane Doe ', 2); INSERT INTO `table_one` VALUES ('Baby S. Doe ...
1
7836
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 in this format: 20031105 14:00? Any advice of links would be appreciated. Thanks in advance -Chris
4
10715
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 of text and putting them into text fields. Cutting and pasting in the command prompt for windows isn't such a good idea. Is there a way to update an existing record by importing a text file into a text field?
5
4715
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 Expected result: column1 1234
6
12357
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 10 columns into a table with 12. How can I specify which columns to insert to? I think format files are what I'm supposed to use, but I can't figure them out. I've also tried using a view, as was suggested on one of the many websites I've...
7
14784
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 char in the middle every time, with realloc() the part of the string before the position where the char has to be inserted is not changed if realloc returns the same pointer is passed, but if not the string is copied at all the first time, and then...
1
5519
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 me out here?
1
1879
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 Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
0
2327
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 i.e(.rpt) file into the BLOB feild of DB2 database. Can any one of you provide a help in solving this issue. Regards
0
1924
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 PreviousToken(Previous word) and frequency and probability From text file and put each one in cell in table For example if the text file content is "Every man has a price. Every woman has a price." First Token(word) is "Every" PreviousToken(Previous...
0
8831
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9326
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9249
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8245
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4607
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4877
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3315
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.