Click here to Skip to main content
15,921,941 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've millions of data(which are in numerical)in excel csv.please help.thanx in advance
Posted
Comments
Sergey Alexandrovich Kryukov 24-Feb-15 23:14pm    
Not using Excel, perhaps. And stopping to pretend that Excel is something like a database... :-)
—SA
[no name] 24-Feb-15 23:30pm    
how to import it? @sergey
Wendelius 24-Feb-15 23:34pm    
Better in which sense, what is currently wrong with bulk insert?
[no name] 24-Feb-15 23:49pm    
It doesn't insert whole data, means data doesn't find. But all rows are affected.

If the data doesn't load properly, there are two parameters you should define
  • BATCHSIZE, try having the BATCHSIZE as 1. This will slow you down but then again you may have different results and that would help you to find the problem

  • ERRORFILE, define a file where the error messages go. After running the import, investigate the contents of this file
 
Share this answer
 
you can use ole automation in sql server like below


declare @OLEResult int,@FS int,@FileID INT,@FileName VARCHAR(100),@Message VARCHAR (8000)
set @filename='C:\test.csv'

-- Open the text file for reading
EXEC @OLEResult = sp_OAMethod @FS, 'OpenTextFile', @FileID OUT, @FileName, 1, 1
IF @OLEResult = 0
-- Read the first line into the @Message variable
EXECUTE @OLEResult = sp_OAMethod @FileID, 'ReadLine', @Message OUT

-- Keep looping through until the @OLEResult variable is < 0; this indicates that the end of the file has been reached.
WHILE @OLEResult >= 0
BEGIN

EXECUTE @OLEResult = sp_OAMethod @FileID, 'ReadLine', @Message OUT
END

EXECUTE @OLEResult = sp_OADestroy @FileID
EXECUTE @OLEResult = sp_OADestroy @FS



regards
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900