Click here to Skip to main content
15,881,516 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I have a text file I want to put it in a table with 14 columns. Text file in the form of a file .txt notpade and the table I want in table in sqlserver  Being in the form of a file with a sample of data I am very grateful and grateful that you can fix the problem because I do not really know how to do it excel file 

notpad --import data in sql server :

https://www.dropbox.com/s/lsw1tgsimlr6z5i/ququ.txt?dl=0

excel sample table and data after insert notpade file ;

https://www.dropbox.com/s/zozykrqp982jbov/sample_ququ.xlsx?dl=0


What I have tried:

USE demo_test
--- Create Table 
IF OBJECT_ID(N'TempDb..MyTemp',N'U') IS NOT NULL DROP TABLE MyTemp

CREATE TABLE MyTemp  (
MyTime           time,
MyEXCEPTION      VARCHAR (1000),
MyActio          VARCHAR (1000) , 
MyJSON           VARCHAR (max)
)
GO


13.0
4
1       SQLCHAR             	0       	8         "\t"      	  	1     			MyTIME               		""
2       SQLCHAR             	0       	1000      "\r\n"      		2        		MyException			SQL_Latin1_General_CP1_CI_AS
3       SQLCHAR             	0       	1000        "\r\n"      	3             		MyAction			SQL_Latin1_General_CP1_CI_AS
4       SQLCHAR             	0       	0      	  "\r\n\r\n"      	4             		MyJSON				SQL_Latin1_General_CP1_CI_AS


BULK INSERT MyTemp
   FROM 'C:\bayat\b.log'  
  WITH (FORMATFILE = 'C:\bayat\LogImp1.fmt');


but ;;;;; error
Msg 4862, Level 16, State 1, Line 15
Cannot bulk load because the file "C:\bayat\LogImp1.fmt" is incomplete or could not be read. Operating system error code (null).
Posted
Comments
Patrice T 28-Aug-18 7:39am    
What the content of 'LogImp1.fmt' file ?
Member 12632819 29-Aug-18 5:30am    
13.0
4
1 SQLCHAR 0 8 "\t" 1 MyTIME ""
2 SQLCHAR 0 1000 "\r\n" 2 MyException SQL_Latin1_General_CP1_CI_AS
3 SQLCHAR 0 1000 "\r\n" 3 MyAction SQL_Latin1_General_CP1_CI_AS
4 SQLCHAR 0 0 "\r\n\r\n" 4 MyJSON SQL_Latin1_General_CP1_CI_AS
Patrice T 29-Aug-18 7:43am    
Use Improve question to update your question.
So that everyone can pay attention to this information.
Richard MacCutchan 28-Aug-18 7:47am    
"the file "C:\bayat\LogImp1.fmt" is incomplete or could not be read."
That message seems quite clear. You need to investigate why the file cannot be read.
[no name] 28-Aug-18 12:24pm    
Why don't you show a few lines of "input data"; the rest is (almost) useless without the former.

If you say you need an NDA ...

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