0

My query is that I have a CSV file with data in the format as accepted by Salesforce and require to do a BULK sync using BULKApi Version 2. I now need to send this data from sql using SP_OAMethod procedures. Tried to move this data into a DB table with a cursor on this table to concat the data and send it using the procedure, but unfortunately failed due to the string length limitation.

Request you to help me understand if there is a process to directly upload the CSV ( similar way we do in postman by selecting the Binary option and loading the CSV file from the path).

Any solution related to this would be greatly appreciated.

Thanking in advance.

I tried to use the below part of the code, and completed the job on Salesforce but did not process any records -

EXEC @ret = sp_OAMethod @token, 'open', NULL, 'PUT', @url, 'true';   
EXEC @ret = sp_OAMethod @token, 'setRequestHeader', NULL, 'Authorization', @authHeader;
EXEC @ret = sp_OAMethod @token, 'setRequestHeader', NULL, 'Content-type', @contentType;
EXEC @ret = sp_OAMethod @token, 'setRequestHeader', NULL, 'content-disposition', "attachment; filename=<path of the csv file with filename.csv>";

I also tried to look for Failed records or successful records using the job id but it did not return anything.

  • _I now need to send this data from sql using SP_OAMethod procedures._ No you don't. There are very specific ways to handle the legacy `sp_OA*` functions correctly, which you are not demonstrating here, and when they are not used correctly they lead to resource leaks, performance problems and compromise of SQL Server stability. Consider using an external process, such as a PowerShell script, to extract the data from SQL Server and upload it to Salesforce. – AlwaysLearning Jan 26 '23 at 21:39
  • thank you for your reply and I will try that. But is there a way to achieve this without PowerShell script?.. also, I am uploading this CSV file with size greater than 8000 – user21020259 Jan 27 '23 at 17:21
  • There are literally hundreds of programming languages and scripting environments out there that can be used to connect to SQL Server to execute queries and then write the results to files. Go for it. – AlwaysLearning Jan 28 '23 at 00:01

0 Answers0