As part my developement I would like to keep all employees document stored in database table rather in folder.
I dont want to store the files in folder and keep the file location in table so that get the file from the location.
I tried my level best in google to search for a code but no luck. I got the code in SQL but while retrieving the document its damaged ie unable to open
Below is the SQL code
Looking for your urgent help.
Storing the document:
Create table dbo.ORStable (doclen bigint, doc varbinary(max)) Insert into dbo.ORStable Select len(bulkcolumn), * from openrowset(bulk 'C:\Users\Divakar\Documents\General files\Travel settlement\8H453869.pdf', SINGLE_BLOB) as r
Retrieving the document:
Declare @SQLcommand nvarchar(4000) set @SQLcommand = 'bcp RMG.dbo.ORStable out C:\Users\Divakar\Documents\8H453869.pdf -c -T -S '+ convert(varchar,@@ServerName) exec xp_cmdshell @SQLcommand