Windows 10: Fix: BEGIN TRY does not work with BULK INSERT on SQL

Discus and support Fix: BEGIN TRY does not work with BULK INSERT on SQL in Windows 10 Tutorials to solve the problem; I have created a stored procedure that does a BULK IMPORT. I wanted to add a bit of fault checking and added a BEGIN TRY and a BEGIN CATCH so that it... Discussion in 'Windows 10 Tutorials' started by Noel, Jun 21, 2018.

  1. Noel New Member

    Fix: BEGIN TRY does not work with BULK INSERT on SQL


    I have created a stored procedure that does a BULK IMPORT. I wanted to add a bit of fault checking and added a BEGIN TRY and a BEGIN CATCH so that it sends an email with the error message if the T-SQL fails. The problem is that the BEGIN CATCH was being skipped and the procedure stops processing with the below error message.

    Msg 4860, Level 16, State 1, Line 2
    Cannot bulk load. The file "C:\temp\fileimport.txt" does not exist.

    To fix the issue what I did is to add the BULK INSERT command in a variable and execute it. This way, the BEGIN CATCH is not ignored or skipped.

    Fix below

    BEGIN TRY
    DECLARE @bulkimport varchar(1000)
    SET @bulkimport = 'BULK INSERT mytable FROM ''C:\temp\fileimport.txt''
    WITH (FIELDTERMINATOR = ''*'', ROWTERMINATOR = ''\n'')'
    EXECUTE (@bulkimport)
    END TRY

    BEGIN CATCH
    SELECT error_message()
    END CATCH

    (41)

    read more...
     
  2. ap1978 Win User

    Bulk Crap Uninstaller 4.3.4


    • Added capability to open update link in web browser
    • Fixed treemap not working correctly with only 1 item on the list
    • Blacklisted "Installer" folder for drive scanning
    • Relaxed overly strict check for questionable directory names
    • Updated rate link to a new website

    Klocman/Bulk-Crap-Uninstaller
    https://github.com/Klocman/Bulk-Crap...ses/tag/v4.3.4
     
    ap1978, Jun 21, 2018
    #2
  3. suraswami Win User
    SQL Question

    Its been a while since I wrote any advanced sql code, here is the statement if it was M$ SQL Server

    MERGE services.corproster corp
    USING (SELECT name FROM seat.corporation_member_tracking)
    AS JoinResult
    ON (corp.name = JoinResult.name)
    WHEN MATCHED AND ISNULL(corp.name, '') <> ISNULL(JoinResult.name, '')
    THEN UPDATE SET corp.name = JoinResult.name
    WHEN NOT MATCHED THEN
    INSERT name VALUES JoinResult.name
    ;

    OR may be try this

    BEGIN TRANSACTION
    UPDATE corp
    set corp.name = source.name
    from services.corproster corp join seat.corporation_member_tracking source
    ON corp.name = source.name
    INSERT INTO services.corproster (name)
    SELECT name FROM seat.corporation_member_tracking
    where name not in (select name from services.corproster)
    COMMIT TRANSACTION

    I would only delete and insert if the table has less rows
     
    suraswami, Jun 21, 2018
    #3
  4. zbook Win User

    Fix: BEGIN TRY does not work with BULK INSERT on SQL

    Programs not working


    In post 26 there were steps listed to fix the operating system corruption.
    Are you able to follow them?
    In post 29 was the suggested dism repair command.
     
    zbook, Jun 21, 2018
    #4
    1 person likes this.
Thema:

Fix: BEGIN TRY does not work with BULK INSERT on SQL

Loading...
  1. Fix: BEGIN TRY does not work with BULK INSERT on SQL - Similar Threads - Fix BEGIN TRY

  2. SQL

    in Windows 10 BSOD Crashes and Debugging
    SQL: Each time I have a Windows 10 update it turns off my SQL, why? How do I stop it doing it https://answers.microsoft.com/en-us/windows/forum/all/sql/715f4d75-306f-45ba-a5a3-a9d418793261
  3. emerge for bulk emails

    in Microsoft Office and 365
    emerge for bulk emails: I am trying to send merged email messages. I can prepare the merge document but after entering the final command of finish the mail merge - I get a message that a program is trying to access my Outlook contact file - I agree to allow the access. But then nothing happens -...
  4. emerge for bulk emails

    in Microsoft Office and 365
    emerge for bulk emails: Currently WORD does not allow choice between Outlook and gmail in sending out messages - it defaults to Outlook. How can this be changed to gmail? Merged document tries to access contact address file rather then the list prepared for the merge - how can this be avoided?...
  5. Thumbnail Image Just showing Icon - No IMAGE SHOWING, tried all fixes, DOES NOT work

    in Windows 10 Network and Sharing
    Thumbnail Image Just showing Icon - No IMAGE SHOWING, tried all fixes, DOES NOT work: OK, This is what I see when I go into my Folder. I can not get it to show my the images. (see what I have tried below, with NO Success) [ATTACH]I have tried the following fixes for this and it DOES NOT WORK. (From another Microsoft Post) Hi Mike, We understand that...
  6. "please insert a disk into SCHC" fix???

    in Windows 10 Drivers and Hardware
    "please insert a disk into SCHC" fix???: I'm trying to make disk images for my raspberry pi but then when i go into the sd card, it says "please insert a disk into SCHC." I tried every fix known, but all of them are useless. Please reply, or i'll strongly think about installing Linux....
  7. Windows netowrking does not work try #2

    in Windows 10 Network and Sharing
    Windows netowrking does not work try #2: PLEASE, PLEASE SOMEONE HELP ME, PLEASE i SHOULD NOT HAVE TO BEG, I DO NOT GET IT, NO ONE CARES, NO ONE BELEIEVES AND NO ONE IS WILLING TO HELP. WHY IS THERE THOUSANDS OF MVP'S? WHY? For years I have made 100+ posts about networking not working and gone to bat with people...
  8. i have a webcam in my laptop but it does not work. i tried some tutorials to fix this but...

    in Windows 10 Drivers and Hardware
    i have a webcam in my laptop but it does not work. i tried some tutorials to fix this but...: need answers https://answers.microsoft.com/en-us/windows/forum/all/i-have-a-webcam-in-my-laptop-but-it-does-not-work/036cfe6c-684c-4b58-b3ba-592f6f2c1787
  9. USB insert sound not working.

    in Windows 10 Drivers and Hardware
    USB insert sound not working.: Okay so I don't know what happened but today I had noticed that when I put in a USB driver it will be recognized but no sound will play when I do. I tried going into system sound events to see if I could fix it but it wouldn't work. Then I tried restarting and shutting down...
  10. HIbernate does not work (and lots of the obvious fixes already tried

    in Windows 10 Support
    HIbernate does not work (and lots of the obvious fixes already tried: Exact description: Hibernate enabled (powercfg -h on) hiberfil.sys file present ( and = RAM) and tons of free space on C:\ When I click hibernate from power menu I see the following (a) Instant black screen but power light still on) (b) No change until I press and hold...