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. Bulk Crap Uninstaller 4.4

    in Windows 10 Software and Apps
    Bulk Crap Uninstaller 4.4: Bulk Crap Uninstaller 4.4 Added support for Chocolatey application manager. Added automatic removal of uninstalled apps from Chocolatey (if possible). Added ability to export uninstall commands to a batch file. Added ability to create a PowerShell script that removes...
  3. A fix that does not make sense

    in Windows 10 Software and Apps
    A fix that does not make sense: My OS is Windows 10 and I have office 2007 installed which I’ve had for quite some time. Every now and then when I open MS Word it goes through the configuration process before it opens. It seems as there are a few different ways to fix it. One way was to go to Control Panel...
  4. 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...
  5. Bulk Crap Uninstaller 4.3.4

    in Windows 10 Software and Apps
    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...
  6. When inserting headphones, built in microphone is not working

    in Windows 10 Drivers and Hardware
    When inserting headphones, built in microphone is not working: When I plugged in my headphones in my laptop, having the newly installed Windows 10, a question came up to select what type of device is this. By mistake, instead to clicking headphones, I clicked headset. From that point the microphone of my laptop did not work anymore, when...
  7. Does OS build interfere with SQL Server UI?

    in Windows 10 Performance & Maintenance
    Does OS build interfere with SQL Server UI?: I am using the following build of OS: Version 1709 OS Build 17025.1000 I have found that the UI elements in Reporting Services, a Windows Service is messed up. https://hodentekmsss.blogspot.com/20...lems-that.html I want to know whether OS Build could do this kind...
  8. Blurry GUI/Text (Fix does not fix!)

    in Windows 10 Support
    Blurry GUI/Text (Fix does not fix!): Hi guys. I got a brand new laptop and updated to windows 10 from windows 8.1. Windows makes me hate windows 10. There were issues like monitor brightness and sound. But now both are fixed after updating the drivers, i guess. Now here is the main problem. I have laptop...
  9. 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...
  10. Rename Files In Bulk with % in Name

    in Windows 10 Support
    Rename Files In Bulk with % in Name: Employee just got a new computer with Windows 10 and has several files that were copied over from another computer that have a % sign in the names. Don't ask me how. She has to rename them. Is there a way to change the % to an underscore in all the files at one time? Thank...