We have a requirement that we need to read the files (PDF, word, excel text, etc.) from the folder and insert them into the database.
Below is the table
CREATE TABLE dbo.file_details |
Below files are need to load in this table.
Let’s see
how to load these files into the table.
Below is the
sql script to load the files.
With the
help of the below script we need to configure the below setting on the server.
USE MASTER GO EXEC sp_configure 'xp_cmdshell', 1; GO RECONFIGURE; GO EXEC sp_configure 'show advanced options', 1; GO RECONFIGURE; GO EXEC sp_configure 'Ole Automation Procedures', 1; GO RECONFIGURE; GO -- Add 'bulkadmin' to the correct user ALTER SERVER ROLE [bulkadmin] ADD MEMBER [NT AUTHORITY\SYSTEM] GO |
Now with the help of below script we will load the files
from the folder.
DECLARE @file_nm VARCHAR(250), |
Before running this script records in the table.
Now running this script.
Record
inserted successfully.
See the records in the table
Data loaded successfully.
No comments:
Post a Comment
If you have any doubt, please let me know.