Read XML data into SQL Server table
I have xml like this (it contains more than 300k):
<?xml version="1.0" encoding="utf-8"?>
<data>
<kitap>
<Adi>Matematik +5 Yaş</Adi>
<Barkod>9786052342046</Barkod>
<Resim>http://xxxx.com.tr/Icerik/Gorsel/Urun/9786052342046.jpg</Resim>
</kitap>
<kitap>
<Adi>Broke - Light (Ciltli)</Adi>
<Barkod>9786057944085</Barkod>
<Resim>http://xxx.com.tr/Icerik/Gorsel/Urun/9786057944085.jpg</Resim>
</kitap>
</data>
I want to store data into a database table.
Here is my T-SQL code:
INSERT INTO ddd (Adi,Barkod,Resim)
SELECT
X.kitap.query('Adi').value('.', 'nvarchar(1000)'),
X.kitap.query('Barkod').value('.', 'nvarchar(1000)'),
X.kitap.query('Resim').value('.', 'nvarchar(1000)')
FROM
(SELECT
CAST(x AS XML)
FROM
OPENROWSET(BULK 'C:silb.xml', SINGLE_BLOB) AS T(x)
) AS T(x)
CROSS APPLY
x.nodes('data/kitap') AS X(kitap);
but I get this error:
Msg 8152, Level 16, State 13, Line 1
String or binary data would be truncated.
sql-server xml xml-parsing
add a comment |
I have xml like this (it contains more than 300k):
<?xml version="1.0" encoding="utf-8"?>
<data>
<kitap>
<Adi>Matematik +5 Yaş</Adi>
<Barkod>9786052342046</Barkod>
<Resim>http://xxxx.com.tr/Icerik/Gorsel/Urun/9786052342046.jpg</Resim>
</kitap>
<kitap>
<Adi>Broke - Light (Ciltli)</Adi>
<Barkod>9786057944085</Barkod>
<Resim>http://xxx.com.tr/Icerik/Gorsel/Urun/9786057944085.jpg</Resim>
</kitap>
</data>
I want to store data into a database table.
Here is my T-SQL code:
INSERT INTO ddd (Adi,Barkod,Resim)
SELECT
X.kitap.query('Adi').value('.', 'nvarchar(1000)'),
X.kitap.query('Barkod').value('.', 'nvarchar(1000)'),
X.kitap.query('Resim').value('.', 'nvarchar(1000)')
FROM
(SELECT
CAST(x AS XML)
FROM
OPENROWSET(BULK 'C:silb.xml', SINGLE_BLOB) AS T(x)
) AS T(x)
CROSS APPLY
x.nodes('data/kitap') AS X(kitap);
but I get this error:
Msg 8152, Level 16, State 13, Line 1
String or binary data would be truncated.
sql-server xml xml-parsing
2
What is the structure of your database tableddd
?? What are the columns, and what is their datatype?
– marc_s
Nov 22 '18 at 20:41
add a comment |
I have xml like this (it contains more than 300k):
<?xml version="1.0" encoding="utf-8"?>
<data>
<kitap>
<Adi>Matematik +5 Yaş</Adi>
<Barkod>9786052342046</Barkod>
<Resim>http://xxxx.com.tr/Icerik/Gorsel/Urun/9786052342046.jpg</Resim>
</kitap>
<kitap>
<Adi>Broke - Light (Ciltli)</Adi>
<Barkod>9786057944085</Barkod>
<Resim>http://xxx.com.tr/Icerik/Gorsel/Urun/9786057944085.jpg</Resim>
</kitap>
</data>
I want to store data into a database table.
Here is my T-SQL code:
INSERT INTO ddd (Adi,Barkod,Resim)
SELECT
X.kitap.query('Adi').value('.', 'nvarchar(1000)'),
X.kitap.query('Barkod').value('.', 'nvarchar(1000)'),
X.kitap.query('Resim').value('.', 'nvarchar(1000)')
FROM
(SELECT
CAST(x AS XML)
FROM
OPENROWSET(BULK 'C:silb.xml', SINGLE_BLOB) AS T(x)
) AS T(x)
CROSS APPLY
x.nodes('data/kitap') AS X(kitap);
but I get this error:
Msg 8152, Level 16, State 13, Line 1
String or binary data would be truncated.
sql-server xml xml-parsing
I have xml like this (it contains more than 300k):
<?xml version="1.0" encoding="utf-8"?>
<data>
<kitap>
<Adi>Matematik +5 Yaş</Adi>
<Barkod>9786052342046</Barkod>
<Resim>http://xxxx.com.tr/Icerik/Gorsel/Urun/9786052342046.jpg</Resim>
</kitap>
<kitap>
<Adi>Broke - Light (Ciltli)</Adi>
<Barkod>9786057944085</Barkod>
<Resim>http://xxx.com.tr/Icerik/Gorsel/Urun/9786057944085.jpg</Resim>
</kitap>
</data>
I want to store data into a database table.
Here is my T-SQL code:
INSERT INTO ddd (Adi,Barkod,Resim)
SELECT
X.kitap.query('Adi').value('.', 'nvarchar(1000)'),
X.kitap.query('Barkod').value('.', 'nvarchar(1000)'),
X.kitap.query('Resim').value('.', 'nvarchar(1000)')
FROM
(SELECT
CAST(x AS XML)
FROM
OPENROWSET(BULK 'C:silb.xml', SINGLE_BLOB) AS T(x)
) AS T(x)
CROSS APPLY
x.nodes('data/kitap') AS X(kitap);
but I get this error:
Msg 8152, Level 16, State 13, Line 1
String or binary data would be truncated.
sql-server xml xml-parsing
sql-server xml xml-parsing
edited Nov 22 '18 at 20:40
marc_s
570k12811031251
570k12811031251
asked Nov 22 '18 at 20:38
user1688401
41632250
41632250
2
What is the structure of your database tableddd
?? What are the columns, and what is their datatype?
– marc_s
Nov 22 '18 at 20:41
add a comment |
2
What is the structure of your database tableddd
?? What are the columns, and what is their datatype?
– marc_s
Nov 22 '18 at 20:41
2
2
What is the structure of your database table
ddd
?? What are the columns, and what is their datatype?– marc_s
Nov 22 '18 at 20:41
What is the structure of your database table
ddd
?? What are the columns, and what is their datatype?– marc_s
Nov 22 '18 at 20:41
add a comment |
1 Answer
1
active
oldest
votes
Well, your XML-query is fine, although I'd simplify it a bit:
DECLARE @xml XML=
'<?xml version="1.0" encoding="utf-8"?>
<data>
<kitap>
<Adi>Matematik +5 Yaş</Adi>
<Barkod>9786052342046</Barkod>
<Resim>http://xxxx.com.tr/Icerik/Gorsel/Urun/9786052342046.jpg</Resim>
</kitap>
<kitap>
<Adi>Broke - Light (Ciltli)</Adi>
<Barkod>9786057944085</Barkod>
<Resim>http://xxx.com.tr/Icerik/Gorsel/Urun/9786057944085.jpg</Resim>
</kitap>
</data>';
SELECT
X.kitap.value('(Adi/text())[1]', 'nvarchar(1000)'),
X.kitap.value('(Barkod/text())[1]', 'nvarchar(1000)'),
X.kitap.value('(Resim/text())[1]', 'nvarchar(1000)')
FROM @xml.nodes('data/kitap') AS X(kitap);
The reason for the error mentioned ("String or binary data would be truncated") is with the length of your target fields assumably. You are reading all three columns as nvarchar(1000)
. Use the following to find the max lengths per column:
SELECT
MAX(LEN(X.kitap.value('(Adi/text())[1]', 'nvarchar(max)'))) AS MaxLenAdi,
MAX(LEN(X.kitap.value('(Barkod/text())[1]', 'nvarchar(max)'))) AS MaxLenBarkod,
MAX(LEN(X.kitap.value('(Resim/text())[1]', 'nvarchar(max)'))) AS MaxLenResim
FROM @xml.nodes('data/kitap') AS X(kitap);
Now check your ddd
table's definition, if the values will fit into 1) nvarchar(1000)
and 2) into the table's columns.
One more thing to mention: Your XML-file is claiming to be utf-8
encoded. Reading this simply as SINGLE_BLOB
might be dangerous... This will call the file as a byte-stream and will take each single byte as a character. But utf-8
uses multi-byte codes to encode all the characters existing in the world. This will either lead to garbage data or to an error.
- Try to import this as
SINGLE_CLOB
(Character LOB - not secure, but a bit better) - Try to import this with
utf-8
support (I think this is available since v2014 SP1) - Use an external tool to convert your file to
utf-16
(even better:ucs-2
)
And one final hint: Very often XML-files claim to have a special encoding (first line declaration <?xml ... encoding="xyz"?>
. Very often people just do not know what this is and think, that this - hoewever - must be there ("Uhm... Don't know... Just copied the template..."). It might be worth to check the file's actual encoding. In general it is a good advise to omit this declaration entirely within SQL-Server.
reading file take too many time ...here is my t-sql INSERT INTO ddd (Adi,Barkod,Resim) SELECT X.kitap.query('Adi').value('.', 'nvarchar(1000)'), X.kitap.query('Barkod').value('.', 'nvarchar(100)'), X.kitap.query('Resim').value('.', 'nvarchar(Max)') FROM ( SELECT CAST(x AS XML) FROM OPENROWSET( BULK 'C:sild.xml', utf-8) AS T(x) ) AS T(x) CROSS APPLY x.nodes('data/kitap') AS X(kitap);
– user1688401
Nov 27 '18 at 12:47
@user1688401 Please avoid follow-up questions, especially when they are not related to the initial question. Rather start a new question. You might place a link to this one, if you think it helps. New questions pull the highest attraction :-) One last hint: "takes to much time" is not specific enough. You must describe in detail, which part is time consuming (how big is the file, measure the time for simple reading, find out, where the time is going...
– Shnugo
Nov 27 '18 at 13:05
Btw: Reading an XML with more than 300k objects will not be fast...
– Shnugo
Nov 27 '18 at 13:06
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53437745%2fread-xml-data-into-sql-server-table%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Well, your XML-query is fine, although I'd simplify it a bit:
DECLARE @xml XML=
'<?xml version="1.0" encoding="utf-8"?>
<data>
<kitap>
<Adi>Matematik +5 Yaş</Adi>
<Barkod>9786052342046</Barkod>
<Resim>http://xxxx.com.tr/Icerik/Gorsel/Urun/9786052342046.jpg</Resim>
</kitap>
<kitap>
<Adi>Broke - Light (Ciltli)</Adi>
<Barkod>9786057944085</Barkod>
<Resim>http://xxx.com.tr/Icerik/Gorsel/Urun/9786057944085.jpg</Resim>
</kitap>
</data>';
SELECT
X.kitap.value('(Adi/text())[1]', 'nvarchar(1000)'),
X.kitap.value('(Barkod/text())[1]', 'nvarchar(1000)'),
X.kitap.value('(Resim/text())[1]', 'nvarchar(1000)')
FROM @xml.nodes('data/kitap') AS X(kitap);
The reason for the error mentioned ("String or binary data would be truncated") is with the length of your target fields assumably. You are reading all three columns as nvarchar(1000)
. Use the following to find the max lengths per column:
SELECT
MAX(LEN(X.kitap.value('(Adi/text())[1]', 'nvarchar(max)'))) AS MaxLenAdi,
MAX(LEN(X.kitap.value('(Barkod/text())[1]', 'nvarchar(max)'))) AS MaxLenBarkod,
MAX(LEN(X.kitap.value('(Resim/text())[1]', 'nvarchar(max)'))) AS MaxLenResim
FROM @xml.nodes('data/kitap') AS X(kitap);
Now check your ddd
table's definition, if the values will fit into 1) nvarchar(1000)
and 2) into the table's columns.
One more thing to mention: Your XML-file is claiming to be utf-8
encoded. Reading this simply as SINGLE_BLOB
might be dangerous... This will call the file as a byte-stream and will take each single byte as a character. But utf-8
uses multi-byte codes to encode all the characters existing in the world. This will either lead to garbage data or to an error.
- Try to import this as
SINGLE_CLOB
(Character LOB - not secure, but a bit better) - Try to import this with
utf-8
support (I think this is available since v2014 SP1) - Use an external tool to convert your file to
utf-16
(even better:ucs-2
)
And one final hint: Very often XML-files claim to have a special encoding (first line declaration <?xml ... encoding="xyz"?>
. Very often people just do not know what this is and think, that this - hoewever - must be there ("Uhm... Don't know... Just copied the template..."). It might be worth to check the file's actual encoding. In general it is a good advise to omit this declaration entirely within SQL-Server.
reading file take too many time ...here is my t-sql INSERT INTO ddd (Adi,Barkod,Resim) SELECT X.kitap.query('Adi').value('.', 'nvarchar(1000)'), X.kitap.query('Barkod').value('.', 'nvarchar(100)'), X.kitap.query('Resim').value('.', 'nvarchar(Max)') FROM ( SELECT CAST(x AS XML) FROM OPENROWSET( BULK 'C:sild.xml', utf-8) AS T(x) ) AS T(x) CROSS APPLY x.nodes('data/kitap') AS X(kitap);
– user1688401
Nov 27 '18 at 12:47
@user1688401 Please avoid follow-up questions, especially when they are not related to the initial question. Rather start a new question. You might place a link to this one, if you think it helps. New questions pull the highest attraction :-) One last hint: "takes to much time" is not specific enough. You must describe in detail, which part is time consuming (how big is the file, measure the time for simple reading, find out, where the time is going...
– Shnugo
Nov 27 '18 at 13:05
Btw: Reading an XML with more than 300k objects will not be fast...
– Shnugo
Nov 27 '18 at 13:06
add a comment |
Well, your XML-query is fine, although I'd simplify it a bit:
DECLARE @xml XML=
'<?xml version="1.0" encoding="utf-8"?>
<data>
<kitap>
<Adi>Matematik +5 Yaş</Adi>
<Barkod>9786052342046</Barkod>
<Resim>http://xxxx.com.tr/Icerik/Gorsel/Urun/9786052342046.jpg</Resim>
</kitap>
<kitap>
<Adi>Broke - Light (Ciltli)</Adi>
<Barkod>9786057944085</Barkod>
<Resim>http://xxx.com.tr/Icerik/Gorsel/Urun/9786057944085.jpg</Resim>
</kitap>
</data>';
SELECT
X.kitap.value('(Adi/text())[1]', 'nvarchar(1000)'),
X.kitap.value('(Barkod/text())[1]', 'nvarchar(1000)'),
X.kitap.value('(Resim/text())[1]', 'nvarchar(1000)')
FROM @xml.nodes('data/kitap') AS X(kitap);
The reason for the error mentioned ("String or binary data would be truncated") is with the length of your target fields assumably. You are reading all three columns as nvarchar(1000)
. Use the following to find the max lengths per column:
SELECT
MAX(LEN(X.kitap.value('(Adi/text())[1]', 'nvarchar(max)'))) AS MaxLenAdi,
MAX(LEN(X.kitap.value('(Barkod/text())[1]', 'nvarchar(max)'))) AS MaxLenBarkod,
MAX(LEN(X.kitap.value('(Resim/text())[1]', 'nvarchar(max)'))) AS MaxLenResim
FROM @xml.nodes('data/kitap') AS X(kitap);
Now check your ddd
table's definition, if the values will fit into 1) nvarchar(1000)
and 2) into the table's columns.
One more thing to mention: Your XML-file is claiming to be utf-8
encoded. Reading this simply as SINGLE_BLOB
might be dangerous... This will call the file as a byte-stream and will take each single byte as a character. But utf-8
uses multi-byte codes to encode all the characters existing in the world. This will either lead to garbage data or to an error.
- Try to import this as
SINGLE_CLOB
(Character LOB - not secure, but a bit better) - Try to import this with
utf-8
support (I think this is available since v2014 SP1) - Use an external tool to convert your file to
utf-16
(even better:ucs-2
)
And one final hint: Very often XML-files claim to have a special encoding (first line declaration <?xml ... encoding="xyz"?>
. Very often people just do not know what this is and think, that this - hoewever - must be there ("Uhm... Don't know... Just copied the template..."). It might be worth to check the file's actual encoding. In general it is a good advise to omit this declaration entirely within SQL-Server.
reading file take too many time ...here is my t-sql INSERT INTO ddd (Adi,Barkod,Resim) SELECT X.kitap.query('Adi').value('.', 'nvarchar(1000)'), X.kitap.query('Barkod').value('.', 'nvarchar(100)'), X.kitap.query('Resim').value('.', 'nvarchar(Max)') FROM ( SELECT CAST(x AS XML) FROM OPENROWSET( BULK 'C:sild.xml', utf-8) AS T(x) ) AS T(x) CROSS APPLY x.nodes('data/kitap') AS X(kitap);
– user1688401
Nov 27 '18 at 12:47
@user1688401 Please avoid follow-up questions, especially when they are not related to the initial question. Rather start a new question. You might place a link to this one, if you think it helps. New questions pull the highest attraction :-) One last hint: "takes to much time" is not specific enough. You must describe in detail, which part is time consuming (how big is the file, measure the time for simple reading, find out, where the time is going...
– Shnugo
Nov 27 '18 at 13:05
Btw: Reading an XML with more than 300k objects will not be fast...
– Shnugo
Nov 27 '18 at 13:06
add a comment |
Well, your XML-query is fine, although I'd simplify it a bit:
DECLARE @xml XML=
'<?xml version="1.0" encoding="utf-8"?>
<data>
<kitap>
<Adi>Matematik +5 Yaş</Adi>
<Barkod>9786052342046</Barkod>
<Resim>http://xxxx.com.tr/Icerik/Gorsel/Urun/9786052342046.jpg</Resim>
</kitap>
<kitap>
<Adi>Broke - Light (Ciltli)</Adi>
<Barkod>9786057944085</Barkod>
<Resim>http://xxx.com.tr/Icerik/Gorsel/Urun/9786057944085.jpg</Resim>
</kitap>
</data>';
SELECT
X.kitap.value('(Adi/text())[1]', 'nvarchar(1000)'),
X.kitap.value('(Barkod/text())[1]', 'nvarchar(1000)'),
X.kitap.value('(Resim/text())[1]', 'nvarchar(1000)')
FROM @xml.nodes('data/kitap') AS X(kitap);
The reason for the error mentioned ("String or binary data would be truncated") is with the length of your target fields assumably. You are reading all three columns as nvarchar(1000)
. Use the following to find the max lengths per column:
SELECT
MAX(LEN(X.kitap.value('(Adi/text())[1]', 'nvarchar(max)'))) AS MaxLenAdi,
MAX(LEN(X.kitap.value('(Barkod/text())[1]', 'nvarchar(max)'))) AS MaxLenBarkod,
MAX(LEN(X.kitap.value('(Resim/text())[1]', 'nvarchar(max)'))) AS MaxLenResim
FROM @xml.nodes('data/kitap') AS X(kitap);
Now check your ddd
table's definition, if the values will fit into 1) nvarchar(1000)
and 2) into the table's columns.
One more thing to mention: Your XML-file is claiming to be utf-8
encoded. Reading this simply as SINGLE_BLOB
might be dangerous... This will call the file as a byte-stream and will take each single byte as a character. But utf-8
uses multi-byte codes to encode all the characters existing in the world. This will either lead to garbage data or to an error.
- Try to import this as
SINGLE_CLOB
(Character LOB - not secure, but a bit better) - Try to import this with
utf-8
support (I think this is available since v2014 SP1) - Use an external tool to convert your file to
utf-16
(even better:ucs-2
)
And one final hint: Very often XML-files claim to have a special encoding (first line declaration <?xml ... encoding="xyz"?>
. Very often people just do not know what this is and think, that this - hoewever - must be there ("Uhm... Don't know... Just copied the template..."). It might be worth to check the file's actual encoding. In general it is a good advise to omit this declaration entirely within SQL-Server.
Well, your XML-query is fine, although I'd simplify it a bit:
DECLARE @xml XML=
'<?xml version="1.0" encoding="utf-8"?>
<data>
<kitap>
<Adi>Matematik +5 Yaş</Adi>
<Barkod>9786052342046</Barkod>
<Resim>http://xxxx.com.tr/Icerik/Gorsel/Urun/9786052342046.jpg</Resim>
</kitap>
<kitap>
<Adi>Broke - Light (Ciltli)</Adi>
<Barkod>9786057944085</Barkod>
<Resim>http://xxx.com.tr/Icerik/Gorsel/Urun/9786057944085.jpg</Resim>
</kitap>
</data>';
SELECT
X.kitap.value('(Adi/text())[1]', 'nvarchar(1000)'),
X.kitap.value('(Barkod/text())[1]', 'nvarchar(1000)'),
X.kitap.value('(Resim/text())[1]', 'nvarchar(1000)')
FROM @xml.nodes('data/kitap') AS X(kitap);
The reason for the error mentioned ("String or binary data would be truncated") is with the length of your target fields assumably. You are reading all three columns as nvarchar(1000)
. Use the following to find the max lengths per column:
SELECT
MAX(LEN(X.kitap.value('(Adi/text())[1]', 'nvarchar(max)'))) AS MaxLenAdi,
MAX(LEN(X.kitap.value('(Barkod/text())[1]', 'nvarchar(max)'))) AS MaxLenBarkod,
MAX(LEN(X.kitap.value('(Resim/text())[1]', 'nvarchar(max)'))) AS MaxLenResim
FROM @xml.nodes('data/kitap') AS X(kitap);
Now check your ddd
table's definition, if the values will fit into 1) nvarchar(1000)
and 2) into the table's columns.
One more thing to mention: Your XML-file is claiming to be utf-8
encoded. Reading this simply as SINGLE_BLOB
might be dangerous... This will call the file as a byte-stream and will take each single byte as a character. But utf-8
uses multi-byte codes to encode all the characters existing in the world. This will either lead to garbage data or to an error.
- Try to import this as
SINGLE_CLOB
(Character LOB - not secure, but a bit better) - Try to import this with
utf-8
support (I think this is available since v2014 SP1) - Use an external tool to convert your file to
utf-16
(even better:ucs-2
)
And one final hint: Very often XML-files claim to have a special encoding (first line declaration <?xml ... encoding="xyz"?>
. Very often people just do not know what this is and think, that this - hoewever - must be there ("Uhm... Don't know... Just copied the template..."). It might be worth to check the file's actual encoding. In general it is a good advise to omit this declaration entirely within SQL-Server.
answered Nov 23 '18 at 7:56
Shnugo
48.6k72566
48.6k72566
reading file take too many time ...here is my t-sql INSERT INTO ddd (Adi,Barkod,Resim) SELECT X.kitap.query('Adi').value('.', 'nvarchar(1000)'), X.kitap.query('Barkod').value('.', 'nvarchar(100)'), X.kitap.query('Resim').value('.', 'nvarchar(Max)') FROM ( SELECT CAST(x AS XML) FROM OPENROWSET( BULK 'C:sild.xml', utf-8) AS T(x) ) AS T(x) CROSS APPLY x.nodes('data/kitap') AS X(kitap);
– user1688401
Nov 27 '18 at 12:47
@user1688401 Please avoid follow-up questions, especially when they are not related to the initial question. Rather start a new question. You might place a link to this one, if you think it helps. New questions pull the highest attraction :-) One last hint: "takes to much time" is not specific enough. You must describe in detail, which part is time consuming (how big is the file, measure the time for simple reading, find out, where the time is going...
– Shnugo
Nov 27 '18 at 13:05
Btw: Reading an XML with more than 300k objects will not be fast...
– Shnugo
Nov 27 '18 at 13:06
add a comment |
reading file take too many time ...here is my t-sql INSERT INTO ddd (Adi,Barkod,Resim) SELECT X.kitap.query('Adi').value('.', 'nvarchar(1000)'), X.kitap.query('Barkod').value('.', 'nvarchar(100)'), X.kitap.query('Resim').value('.', 'nvarchar(Max)') FROM ( SELECT CAST(x AS XML) FROM OPENROWSET( BULK 'C:sild.xml', utf-8) AS T(x) ) AS T(x) CROSS APPLY x.nodes('data/kitap') AS X(kitap);
– user1688401
Nov 27 '18 at 12:47
@user1688401 Please avoid follow-up questions, especially when they are not related to the initial question. Rather start a new question. You might place a link to this one, if you think it helps. New questions pull the highest attraction :-) One last hint: "takes to much time" is not specific enough. You must describe in detail, which part is time consuming (how big is the file, measure the time for simple reading, find out, where the time is going...
– Shnugo
Nov 27 '18 at 13:05
Btw: Reading an XML with more than 300k objects will not be fast...
– Shnugo
Nov 27 '18 at 13:06
reading file take too many time ...here is my t-sql INSERT INTO ddd (Adi,Barkod,Resim) SELECT X.kitap.query('Adi').value('.', 'nvarchar(1000)'), X.kitap.query('Barkod').value('.', 'nvarchar(100)'), X.kitap.query('Resim').value('.', 'nvarchar(Max)') FROM ( SELECT CAST(x AS XML) FROM OPENROWSET( BULK 'C:sild.xml', utf-8) AS T(x) ) AS T(x) CROSS APPLY x.nodes('data/kitap') AS X(kitap);
– user1688401
Nov 27 '18 at 12:47
reading file take too many time ...here is my t-sql INSERT INTO ddd (Adi,Barkod,Resim) SELECT X.kitap.query('Adi').value('.', 'nvarchar(1000)'), X.kitap.query('Barkod').value('.', 'nvarchar(100)'), X.kitap.query('Resim').value('.', 'nvarchar(Max)') FROM ( SELECT CAST(x AS XML) FROM OPENROWSET( BULK 'C:sild.xml', utf-8) AS T(x) ) AS T(x) CROSS APPLY x.nodes('data/kitap') AS X(kitap);
– user1688401
Nov 27 '18 at 12:47
@user1688401 Please avoid follow-up questions, especially when they are not related to the initial question. Rather start a new question. You might place a link to this one, if you think it helps. New questions pull the highest attraction :-) One last hint: "takes to much time" is not specific enough. You must describe in detail, which part is time consuming (how big is the file, measure the time for simple reading, find out, where the time is going...
– Shnugo
Nov 27 '18 at 13:05
@user1688401 Please avoid follow-up questions, especially when they are not related to the initial question. Rather start a new question. You might place a link to this one, if you think it helps. New questions pull the highest attraction :-) One last hint: "takes to much time" is not specific enough. You must describe in detail, which part is time consuming (how big is the file, measure the time for simple reading, find out, where the time is going...
– Shnugo
Nov 27 '18 at 13:05
Btw: Reading an XML with more than 300k objects will not be fast...
– Shnugo
Nov 27 '18 at 13:06
Btw: Reading an XML with more than 300k objects will not be fast...
– Shnugo
Nov 27 '18 at 13:06
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53437745%2fread-xml-data-into-sql-server-table%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
What is the structure of your database table
ddd
?? What are the columns, and what is their datatype?– marc_s
Nov 22 '18 at 20:41