BULK INSERT some rows being added with quotation marks











up vote
0
down vote

favorite












I'm attempting to BULK INSERT a tab-separated text file into a database only containing VARCHAR data. For some reason, some of the data is getting double quotation marks placed around it randomly, while other rows do not:



domain      sku         type    product
amazon.com b0071n529i laptop hp_4535s_a7k08ut#aba_15.6-inch_laptop
amazon.com b00715sj82 laptop "dell_64gb_mini_pcie_ssd_pata,_f462n"


The statement I'm using looks like this:



BULK INSERT database
FROM 'file.txt' WITH (FIRSTROW = 1, FIELDTERMINATOR = 't', ROWTERMINATOR = '0x0a');









share|improve this question
























  • If you use a terminator (in your case the tab), which might occur within a text as well, the usual approach is to use text qualifiers. In most cases this is the double quote. Just imagine a CSV with the semi-colon as delimitier and a row like 1;2;This is a text;and it continues. The engine would not know, that there is a semi-colon as part of the text and would cut the string. The solution 1;2;"This is a text;and it continues". Check if the quoted strings include a tab...
    – Shnugo
    Nov 11 at 11:14















up vote
0
down vote

favorite












I'm attempting to BULK INSERT a tab-separated text file into a database only containing VARCHAR data. For some reason, some of the data is getting double quotation marks placed around it randomly, while other rows do not:



domain      sku         type    product
amazon.com b0071n529i laptop hp_4535s_a7k08ut#aba_15.6-inch_laptop
amazon.com b00715sj82 laptop "dell_64gb_mini_pcie_ssd_pata,_f462n"


The statement I'm using looks like this:



BULK INSERT database
FROM 'file.txt' WITH (FIRSTROW = 1, FIELDTERMINATOR = 't', ROWTERMINATOR = '0x0a');









share|improve this question
























  • If you use a terminator (in your case the tab), which might occur within a text as well, the usual approach is to use text qualifiers. In most cases this is the double quote. Just imagine a CSV with the semi-colon as delimitier and a row like 1;2;This is a text;and it continues. The engine would not know, that there is a semi-colon as part of the text and would cut the string. The solution 1;2;"This is a text;and it continues". Check if the quoted strings include a tab...
    – Shnugo
    Nov 11 at 11:14













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm attempting to BULK INSERT a tab-separated text file into a database only containing VARCHAR data. For some reason, some of the data is getting double quotation marks placed around it randomly, while other rows do not:



domain      sku         type    product
amazon.com b0071n529i laptop hp_4535s_a7k08ut#aba_15.6-inch_laptop
amazon.com b00715sj82 laptop "dell_64gb_mini_pcie_ssd_pata,_f462n"


The statement I'm using looks like this:



BULK INSERT database
FROM 'file.txt' WITH (FIRSTROW = 1, FIELDTERMINATOR = 't', ROWTERMINATOR = '0x0a');









share|improve this question















I'm attempting to BULK INSERT a tab-separated text file into a database only containing VARCHAR data. For some reason, some of the data is getting double quotation marks placed around it randomly, while other rows do not:



domain      sku         type    product
amazon.com b0071n529i laptop hp_4535s_a7k08ut#aba_15.6-inch_laptop
amazon.com b00715sj82 laptop "dell_64gb_mini_pcie_ssd_pata,_f462n"


The statement I'm using looks like this:



BULK INSERT database
FROM 'file.txt' WITH (FIRSTROW = 1, FIELDTERMINATOR = 't', ROWTERMINATOR = '0x0a');






sql-server tsql






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 11 at 8:37









marc_s

567k12710961246




567k12710961246










asked Nov 11 at 2:30









tsb8m

254




254












  • If you use a terminator (in your case the tab), which might occur within a text as well, the usual approach is to use text qualifiers. In most cases this is the double quote. Just imagine a CSV with the semi-colon as delimitier and a row like 1;2;This is a text;and it continues. The engine would not know, that there is a semi-colon as part of the text and would cut the string. The solution 1;2;"This is a text;and it continues". Check if the quoted strings include a tab...
    – Shnugo
    Nov 11 at 11:14


















  • If you use a terminator (in your case the tab), which might occur within a text as well, the usual approach is to use text qualifiers. In most cases this is the double quote. Just imagine a CSV with the semi-colon as delimitier and a row like 1;2;This is a text;and it continues. The engine would not know, that there is a semi-colon as part of the text and would cut the string. The solution 1;2;"This is a text;and it continues". Check if the quoted strings include a tab...
    – Shnugo
    Nov 11 at 11:14
















If you use a terminator (in your case the tab), which might occur within a text as well, the usual approach is to use text qualifiers. In most cases this is the double quote. Just imagine a CSV with the semi-colon as delimitier and a row like 1;2;This is a text;and it continues. The engine would not know, that there is a semi-colon as part of the text and would cut the string. The solution 1;2;"This is a text;and it continues". Check if the quoted strings include a tab...
– Shnugo
Nov 11 at 11:14




If you use a terminator (in your case the tab), which might occur within a text as well, the usual approach is to use text qualifiers. In most cases this is the double quote. Just imagine a CSV with the semi-colon as delimitier and a row like 1;2;This is a text;and it continues. The engine would not know, that there is a semi-colon as part of the text and would cut the string. The solution 1;2;"This is a text;and it continues". Check if the quoted strings include a tab...
– Shnugo
Nov 11 at 11:14












1 Answer
1






active

oldest

votes

















up vote
0
down vote













If your issue is those double quotes then you can do this after insertion that would be the better solution,



UPDATE TABLE A
SET A.Product=Replace(A.Product,'"','')
Where Left(A.Product,1)='"' or Right(A.Product,1)='"'





share|improve this answer





















  • My issue is the double quotes. And yes, a replace would fix the issue... but why are they being added in the first place? They aren't in my txt file.
    – tsb8m
    Nov 11 at 3:05










  • could you check this,
    – Ajan Balakumaran
    Nov 11 at 3:08










  • stackoverflow.com/questions/12902110/…
    – Ajan Balakumaran
    Nov 11 at 3:08










  • from what i see the double quotation you are getting is a text qualifier, so if you can set that as text qualifier you won't get that.
    – Ajan Balakumaran
    Nov 11 at 3:10










  • My text file doesn't have any double quotes though... tabs are my text qualifier.
    – tsb8m
    Nov 11 at 4:49











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',
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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245341%2fbulk-insert-some-rows-being-added-with-quotation-marks%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








up vote
0
down vote













If your issue is those double quotes then you can do this after insertion that would be the better solution,



UPDATE TABLE A
SET A.Product=Replace(A.Product,'"','')
Where Left(A.Product,1)='"' or Right(A.Product,1)='"'





share|improve this answer





















  • My issue is the double quotes. And yes, a replace would fix the issue... but why are they being added in the first place? They aren't in my txt file.
    – tsb8m
    Nov 11 at 3:05










  • could you check this,
    – Ajan Balakumaran
    Nov 11 at 3:08










  • stackoverflow.com/questions/12902110/…
    – Ajan Balakumaran
    Nov 11 at 3:08










  • from what i see the double quotation you are getting is a text qualifier, so if you can set that as text qualifier you won't get that.
    – Ajan Balakumaran
    Nov 11 at 3:10










  • My text file doesn't have any double quotes though... tabs are my text qualifier.
    – tsb8m
    Nov 11 at 4:49















up vote
0
down vote













If your issue is those double quotes then you can do this after insertion that would be the better solution,



UPDATE TABLE A
SET A.Product=Replace(A.Product,'"','')
Where Left(A.Product,1)='"' or Right(A.Product,1)='"'





share|improve this answer





















  • My issue is the double quotes. And yes, a replace would fix the issue... but why are they being added in the first place? They aren't in my txt file.
    – tsb8m
    Nov 11 at 3:05










  • could you check this,
    – Ajan Balakumaran
    Nov 11 at 3:08










  • stackoverflow.com/questions/12902110/…
    – Ajan Balakumaran
    Nov 11 at 3:08










  • from what i see the double quotation you are getting is a text qualifier, so if you can set that as text qualifier you won't get that.
    – Ajan Balakumaran
    Nov 11 at 3:10










  • My text file doesn't have any double quotes though... tabs are my text qualifier.
    – tsb8m
    Nov 11 at 4:49













up vote
0
down vote










up vote
0
down vote









If your issue is those double quotes then you can do this after insertion that would be the better solution,



UPDATE TABLE A
SET A.Product=Replace(A.Product,'"','')
Where Left(A.Product,1)='"' or Right(A.Product,1)='"'





share|improve this answer












If your issue is those double quotes then you can do this after insertion that would be the better solution,



UPDATE TABLE A
SET A.Product=Replace(A.Product,'"','')
Where Left(A.Product,1)='"' or Right(A.Product,1)='"'






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 11 at 2:39









Ajan Balakumaran

50229




50229












  • My issue is the double quotes. And yes, a replace would fix the issue... but why are they being added in the first place? They aren't in my txt file.
    – tsb8m
    Nov 11 at 3:05










  • could you check this,
    – Ajan Balakumaran
    Nov 11 at 3:08










  • stackoverflow.com/questions/12902110/…
    – Ajan Balakumaran
    Nov 11 at 3:08










  • from what i see the double quotation you are getting is a text qualifier, so if you can set that as text qualifier you won't get that.
    – Ajan Balakumaran
    Nov 11 at 3:10










  • My text file doesn't have any double quotes though... tabs are my text qualifier.
    – tsb8m
    Nov 11 at 4:49


















  • My issue is the double quotes. And yes, a replace would fix the issue... but why are they being added in the first place? They aren't in my txt file.
    – tsb8m
    Nov 11 at 3:05










  • could you check this,
    – Ajan Balakumaran
    Nov 11 at 3:08










  • stackoverflow.com/questions/12902110/…
    – Ajan Balakumaran
    Nov 11 at 3:08










  • from what i see the double quotation you are getting is a text qualifier, so if you can set that as text qualifier you won't get that.
    – Ajan Balakumaran
    Nov 11 at 3:10










  • My text file doesn't have any double quotes though... tabs are my text qualifier.
    – tsb8m
    Nov 11 at 4:49
















My issue is the double quotes. And yes, a replace would fix the issue... but why are they being added in the first place? They aren't in my txt file.
– tsb8m
Nov 11 at 3:05




My issue is the double quotes. And yes, a replace would fix the issue... but why are they being added in the first place? They aren't in my txt file.
– tsb8m
Nov 11 at 3:05












could you check this,
– Ajan Balakumaran
Nov 11 at 3:08




could you check this,
– Ajan Balakumaran
Nov 11 at 3:08












stackoverflow.com/questions/12902110/…
– Ajan Balakumaran
Nov 11 at 3:08




stackoverflow.com/questions/12902110/…
– Ajan Balakumaran
Nov 11 at 3:08












from what i see the double quotation you are getting is a text qualifier, so if you can set that as text qualifier you won't get that.
– Ajan Balakumaran
Nov 11 at 3:10




from what i see the double quotation you are getting is a text qualifier, so if you can set that as text qualifier you won't get that.
– Ajan Balakumaran
Nov 11 at 3:10












My text file doesn't have any double quotes though... tabs are my text qualifier.
– tsb8m
Nov 11 at 4:49




My text file doesn't have any double quotes though... tabs are my text qualifier.
– tsb8m
Nov 11 at 4:49


















draft saved

draft discarded




















































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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245341%2fbulk-insert-some-rows-being-added-with-quotation-marks%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

Florida Star v. B. J. F.

Error while running script in elastic search , gateway timeout

Adding quotations to stringified JSON object values