Import Multiple CSV Files into SQL Server using stored procedure.

Поділитися
Вставка
  • Опубліковано 8 вер 2024
  • Import Multiple CSV Files into SQL Server using stored procedure.
    Download sample csv and SQL Scripts from: jsts-thinkbeyo...

КОМЕНТАРІ • 8

  • @user-wt6rl8vz6y
    @user-wt6rl8vz6y 4 місяці тому

    Hello, Joseph Lusoma!
    Thank you very much!
    Your video helps me a lot 👍🏻👍🏻

  • @user-th2od9rk3l
    @user-th2od9rk3l Рік тому +1

    A few points: I had to remove the last '\' from the path and use [FROM "'+@filepath+'\'+@fileName+'" WITH].
    I also had to handle the permission to execute a Cmd instruction with
    [- this turns on advanced options and is needed to configure xp_cmdshell
    EXEC sp_configure 'show advanced options', '1'
    RECONFIGURE
    -- this enables xp_cmdshell
    EXEC sp_configure 'xp_cmdshell', '1'
    RECONFIGURE]
    And align the various ID and filesName spellings.
    Otherwise works great. THANK YOU

  • @m74w
    @m74w Рік тому +1

    One nice topic would be how to make recursive calculations in SQL server

  • @NilserTejedoVega
    @NilserTejedoVega 2 роки тому +1

    Thank you, It help me alot

  • @togaramutasa9669
    @togaramutasa9669 2 роки тому +1

    Thank you Joseph Lusoma. Coming from Oracle database investigating SQL Server equivalents of some funtionality that we have in Oracle database. So question, does the SQL Server Stored procedure T-SQL (sepcifically this BULK INSERT command) handle exceptions in a case there is an error with one of the records? Also it seems your example is for multiple files going into the same single table?

    • @jsts-thinkbeyondcode
      @jsts-thinkbeyondcode  2 роки тому

      Hello Togara, BULK INSERT will only throw an exception, you would have to add another layer of T-SQL code to handle exception's thrown. i.e you can use TRY.. CATCH.
      In the Video i use a single database table however it is possible to improve the code and import data into multiple tables basing on i.e filenames or row contents