Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Reading a file

Author  Topic 

shajimanjeri
Posting Yak Master

179 Posts

Posted - 2008-06-24 : 10:02:10
I am storing one text file on the server.This text file contains some mobile numbers.The file look like
009198XXXXXXXX
009198XXXXXXXX
009198XXXXXXXX
009198XXXXXXXX
etc

Here I need to read this text file row by row mobile number and then insert these mobile numbers into a table by using sql procedure or sql trigger or any other method or coding. Is it is possible or not?
If so then anybody can help me!

regards
Shaji

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-06-24 : 10:12:19
Read about bulk insert in sql server help file

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

shajimanjeri
Posting Yak Master

179 Posts

Posted - 2008-06-25 : 02:53:34
Here I created one txt file on C drive. which contains some names like
shaji
alex


My database table CSVTest structure is
Id (numeric auto increment)
FirstName (varchar)

now I used this bulk query
BULK INSERT CSVTest
FROM 'c:\a.txt'
WITH
(
ROWTERMINATOR = '\n'
)
When I run this query it shows
"Server: Msg 4832, Level 16, State 1, Line 1
Bulk Insert: Unexpected end-of-file (EOF) encountered in data file.
Server: Msg 7399, Level 16, State 1, Line 1
OLE DB provider 'STREAM' reported an error. The provider did not give any information about the error.
The statement has been terminated" error
can any body correct it please?
Go to Top of Page

shajimanjeri
Posting Yak Master

179 Posts

Posted - 2008-06-25 : 03:39:40
Its ok thanks everybody.
Its working after I make some changes...
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-25 : 03:41:01
quote:
Originally posted by shajimanjeri

Its ok thanks everybody.
Its working after I make some changes...


What was the change made? You can post it if you think somebody might benefit from it in future.
Go to Top of Page
   

- Advertisement -