Last post Jan 29, 2018 02:02 PM by PatriceSc
Jan 29, 2018 12:34 PM|NAF|LINK
im trying to insert html file into the database , but its not WORKING AT ALL !!!!!
Below is my code
create table dbo.articles (
id int identity (1, 1) not null,
alter table dbo.articles add constraint PK_articles primary key clustered (
insert into dbo.articles (title, content)
select 'AIO_Dos', BulkColumn
from OPENROWSET (BULK 'D:\articles\AIO_Dos.html', SINGLE_CLOB) AS t;
Any suggestion ??????
Jan 29, 2018 12:52 PM|PatriceSc|LINK
Rather than telling that "it doesn't work" and showing some code that should work, I would suggest to never post about an error witthout telling which error message you have (or the best English translation you can).
For now my guess is that the SQL Server account is not allowed to access to this file making this to fail. Why do you just ignore the error message that tells you what is wrong ?
Jan 29, 2018 12:56 PM|NAF|LINK
if there were an error I would have showed you and mentioned it , im only getting in the query result :
(1 row(s) affected)
the file name is inserted , but the HTML is NOT .....
I AM NOT Ignoring the error , and I will NOT ACCEPT THE WAY that you are talking ....
Jan 29, 2018 01:06 PM|PatriceSc|LINK
Sorry if you found this offending but it's just easier to help when knowing EXACTLY what happens (and posting about an error without teling what it is is quite common).
So right after that if using SELECT id,len(content) from articles you are seeing 0 or NULL rather than the length of the file?
Jan 29, 2018 01:25 PM|NAF|LINK
i have uploaded the images
Jan 29, 2018 01:36 PM|PatriceSc|LINK
I would still show LEN(content). Have you tried to see if it could be that the HTML file starts with white spaces or maybe a new line ?
Jan 29, 2018 01:38 PM|NAF|LINK
id (No column name)
im begenning to suspect that the error is with the html file itself , below if the innerHTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<head><meta name="MustUpdate" http-equiv="Content-Type" content="text/html;">
<title>الدستور الكويتي (رقم: 0 / 1962)</title>
<link href="/WordFiles.css" rel="stylesheet" type="text/css" /> <link href="/StyleSheet.css" rel="stylesheet" type="text/css" />
<body><p id="HeaderP" class="HeaderP" ></p>
<div class="x__1602___1575___1606___1608___1606_"><a name="Anchor1"></a>دستور
<div class="x__1578___1575___1585___1610___1582_" style="display:none;"><a name="Anchor3"></a>صادر
<div class="x__1578___1575___1585___1610___1582_" style="display:none;"><a name="Anchor5"></a>الموافق
فيه 14 جمادي
<div class="x__1593___1606___1608___1575___1606____1604___1604___1602___1575___1606___1608___1606_"><a name="Anchor8"></a>دستور
Jan 29, 2018 01:49 PM|PatriceSc|LINK
If I copy paste your content to a test file it seems to work fine and I see it starts with <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> etc...
I suspect the source file may have whitespaces to begin with. Maybe also an encoding issue. Ah it is Unicode ?
What if you try SINGLE_NCLOB instead of SINGLE_CLOB ?
Humm: seems to be checked and shows an error if it doesn't match (unless maybe the file doesn't have a byte order mark ????)
Jan 29, 2018 01:54 PM|NAF|LINK
seems it worked ,
when I queried :
SELECT content from articles
i got the html data , and i called the data from datareader into FCKEDITOR , and it was loaded .
thank you for your assistance.
Jan 29, 2018 02:02 PM|PatriceSc|LINK
Great to see it is solved and sorry again if I sounded rude.
You could also try LTRIM(content) to see if you had white spaces or UNICODE(content) to see what is the character code for those "invisible" left most characters...