Safe way to BULK INSERT a CSV file in SQL SERVERBest way to get identity of inserted row?Add a column with a default value to an existing table in SQL ServerHow to return only the Date from a SQL Server DateTime datatypeHow to check if a column exists in a SQL Server table?Check if table exists in SQL ServerHow to concatenate text from multiple rows into a single text string in SQL server?LEFT JOIN vs. LEFT OUTER JOIN in SQL ServerInserting multiple rows in a single SQL query?How do I UPDATE from a SELECT in SQL Server?how to import file csv without using bulk insert query?

Insert str into larger str in the most pythonic way

Should I leave the first authourship of our paper to the student who did the project whereas I solved it?

Can a magnet rip protons from a nucleus?

Why was "leaping into the river" a valid trial outcome to prove one's innocence?

Are Democrats more likely to believe Astrology is a science?

How do email clients "send later" without storing a password?

Relevance of the Resurrection

How do I politely hint customers to leave my store, without pretending to need leave store myself?

A Little Riddle

Can I cast Sunbeam if both my hands are busy?

Is the union of a chain of elementary embeddings elementary?

Do ibuprofen or paracetamol cause hearing loss?

What is the purpose of libraries like Pyomo and Google OR tools?

How can I protect myself in case of a human attack like the murders of the hikers Jespersen and Ueland in Morocco?

Evidence that matrix multiplication cannot be done in O(n^2 poly(log(n))) time

Random point on a sphere

Why did they ever make smaller than full-frame sensors?

Can I use ratchet straps to lift a dolly into a truck bed?

Have there been any countries that voted themselves out of existence?

How can I locate a missing person abroad?

Why do sellers care about down payments?

Might have gotten a coworker sick, should I address this?

Is Salesforce Classic being deprecated?

Are programming languages necessary/useful for operations research practitioner?



Safe way to BULK INSERT a CSV file in SQL SERVER


Best way to get identity of inserted row?Add a column with a default value to an existing table in SQL ServerHow to return only the Date from a SQL Server DateTime datatypeHow to check if a column exists in a SQL Server table?Check if table exists in SQL ServerHow to concatenate text from multiple rows into a single text string in SQL server?LEFT JOIN vs. LEFT OUTER JOIN in SQL ServerInserting multiple rows in a single SQL query?How do I UPDATE from a SELECT in SQL Server?how to import file csv without using bulk insert query?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















AS many before, I've fallen into the BULK INSERT hell with SQL Server and CSV files. I've tried to follow basically all the previous anwers but with no luck.



e.g.



'BULK INSERT ' + @Table
+ ' FROM ''' + @Path + @Table + '.csv'' WITH (
FIRSTROW = 2, FIELDTERMINATOR = '';'', ROWTERMINATOR = ''rn'', TABLOCK ) '


Good thing is I can create the CSV files from scratch (I'm on windows, but i'd need them to work in Linux as well.)



Is there a safe methodcode combination to create a CSV file on Windows that will be read by BULK INSERT in both Linux and Windows?



Thank you in advance.










share|improve this question
























  • I would change the ROWTERMINATOR from '' r n'' to ''0x0a''

    – Killer Queen
    Mar 28 at 10:38











  • Read what you wrote. If you knew nothing about this code, your data, your schema, and the process used, would you be able to provide any help? What does "no luck" mean? Is the problem with your construction of dynamic sql? Is it with the execution of your dynamic sql? Maybe permissions to the randomly named file you attempt to insert? Maybe you should use a different approach - not one based on executing this from the server instance but from a client machine?

    – SMor
    Mar 28 at 12:50

















0















AS many before, I've fallen into the BULK INSERT hell with SQL Server and CSV files. I've tried to follow basically all the previous anwers but with no luck.



e.g.



'BULK INSERT ' + @Table
+ ' FROM ''' + @Path + @Table + '.csv'' WITH (
FIRSTROW = 2, FIELDTERMINATOR = '';'', ROWTERMINATOR = ''rn'', TABLOCK ) '


Good thing is I can create the CSV files from scratch (I'm on windows, but i'd need them to work in Linux as well.)



Is there a safe methodcode combination to create a CSV file on Windows that will be read by BULK INSERT in both Linux and Windows?



Thank you in advance.










share|improve this question
























  • I would change the ROWTERMINATOR from '' r n'' to ''0x0a''

    – Killer Queen
    Mar 28 at 10:38











  • Read what you wrote. If you knew nothing about this code, your data, your schema, and the process used, would you be able to provide any help? What does "no luck" mean? Is the problem with your construction of dynamic sql? Is it with the execution of your dynamic sql? Maybe permissions to the randomly named file you attempt to insert? Maybe you should use a different approach - not one based on executing this from the server instance but from a client machine?

    – SMor
    Mar 28 at 12:50













0












0








0








AS many before, I've fallen into the BULK INSERT hell with SQL Server and CSV files. I've tried to follow basically all the previous anwers but with no luck.



e.g.



'BULK INSERT ' + @Table
+ ' FROM ''' + @Path + @Table + '.csv'' WITH (
FIRSTROW = 2, FIELDTERMINATOR = '';'', ROWTERMINATOR = ''rn'', TABLOCK ) '


Good thing is I can create the CSV files from scratch (I'm on windows, but i'd need them to work in Linux as well.)



Is there a safe methodcode combination to create a CSV file on Windows that will be read by BULK INSERT in both Linux and Windows?



Thank you in advance.










share|improve this question














AS many before, I've fallen into the BULK INSERT hell with SQL Server and CSV files. I've tried to follow basically all the previous anwers but with no luck.



e.g.



'BULK INSERT ' + @Table
+ ' FROM ''' + @Path + @Table + '.csv'' WITH (
FIRSTROW = 2, FIELDTERMINATOR = '';'', ROWTERMINATOR = ''rn'', TABLOCK ) '


Good thing is I can create the CSV files from scratch (I'm on windows, but i'd need them to work in Linux as well.)



Is there a safe methodcode combination to create a CSV file on Windows that will be read by BULK INSERT in both Linux and Windows?



Thank you in advance.







sql-server bulkinsert






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 28 at 8:57









Fed CFed C

86 bronze badges




86 bronze badges















  • I would change the ROWTERMINATOR from '' r n'' to ''0x0a''

    – Killer Queen
    Mar 28 at 10:38











  • Read what you wrote. If you knew nothing about this code, your data, your schema, and the process used, would you be able to provide any help? What does "no luck" mean? Is the problem with your construction of dynamic sql? Is it with the execution of your dynamic sql? Maybe permissions to the randomly named file you attempt to insert? Maybe you should use a different approach - not one based on executing this from the server instance but from a client machine?

    – SMor
    Mar 28 at 12:50

















  • I would change the ROWTERMINATOR from '' r n'' to ''0x0a''

    – Killer Queen
    Mar 28 at 10:38











  • Read what you wrote. If you knew nothing about this code, your data, your schema, and the process used, would you be able to provide any help? What does "no luck" mean? Is the problem with your construction of dynamic sql? Is it with the execution of your dynamic sql? Maybe permissions to the randomly named file you attempt to insert? Maybe you should use a different approach - not one based on executing this from the server instance but from a client machine?

    – SMor
    Mar 28 at 12:50
















I would change the ROWTERMINATOR from '' r n'' to ''0x0a''

– Killer Queen
Mar 28 at 10:38





I would change the ROWTERMINATOR from '' r n'' to ''0x0a''

– Killer Queen
Mar 28 at 10:38













Read what you wrote. If you knew nothing about this code, your data, your schema, and the process used, would you be able to provide any help? What does "no luck" mean? Is the problem with your construction of dynamic sql? Is it with the execution of your dynamic sql? Maybe permissions to the randomly named file you attempt to insert? Maybe you should use a different approach - not one based on executing this from the server instance but from a client machine?

– SMor
Mar 28 at 12:50





Read what you wrote. If you knew nothing about this code, your data, your schema, and the process used, would you be able to provide any help? What does "no luck" mean? Is the problem with your construction of dynamic sql? Is it with the execution of your dynamic sql? Maybe permissions to the randomly named file you attempt to insert? Maybe you should use a different approach - not one based on executing this from the server instance but from a client machine?

– SMor
Mar 28 at 12:50












1 Answer
1






active

oldest

votes


















0
















In the end, I've been able to solve it by using ANSI encoding and by substituting all the ; with ,. The code I used is the following: 'BULK INSERT ' + @Table + ' FROM ''' + @Path + @Table + '.csv'' WITH ( FIRSTROW = 2, FIELDTERMINATOR = '','', ROWTERMINATOR = ''n'')'






share|improve this answer
























    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/4.0/"u003ecc by-sa 4.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%2f55393539%2fsafe-way-to-bulk-insert-a-csv-file-in-sql-server%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









    0
















    In the end, I've been able to solve it by using ANSI encoding and by substituting all the ; with ,. The code I used is the following: 'BULK INSERT ' + @Table + ' FROM ''' + @Path + @Table + '.csv'' WITH ( FIRSTROW = 2, FIELDTERMINATOR = '','', ROWTERMINATOR = ''n'')'






    share|improve this answer





























      0
















      In the end, I've been able to solve it by using ANSI encoding and by substituting all the ; with ,. The code I used is the following: 'BULK INSERT ' + @Table + ' FROM ''' + @Path + @Table + '.csv'' WITH ( FIRSTROW = 2, FIELDTERMINATOR = '','', ROWTERMINATOR = ''n'')'






      share|improve this answer



























        0














        0










        0









        In the end, I've been able to solve it by using ANSI encoding and by substituting all the ; with ,. The code I used is the following: 'BULK INSERT ' + @Table + ' FROM ''' + @Path + @Table + '.csv'' WITH ( FIRSTROW = 2, FIELDTERMINATOR = '','', ROWTERMINATOR = ''n'')'






        share|improve this answer













        In the end, I've been able to solve it by using ANSI encoding and by substituting all the ; with ,. The code I used is the following: 'BULK INSERT ' + @Table + ' FROM ''' + @Path + @Table + '.csv'' WITH ( FIRSTROW = 2, FIELDTERMINATOR = '','', ROWTERMINATOR = ''n'')'







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 29 at 11:33









        Fed CFed C

        86 bronze badges




        86 bronze badges





















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.




















            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55393539%2fsafe-way-to-bulk-insert-a-csv-file-in-sql-server%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

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript