The Stored Procedure is like this
CREATE PROCEDURE [dbo].[InsertItemsSPRoc]
-- Add the parameters for the stored procedure here
@File_Name nvarchar(400) = NULL, -- file name to be inserted
@Path_File_Name nvarchar(400) = NULL, -- path file name to be inserted
-- insert in the Media_Files FILETABLE
-- set the specific table holder
set @sql = N'insert into Media_Files (name, file_stream) (SELECT ''' + @File_Name + ''', * FROM OPENROWSET(BULK N''' + @Path_File_Name + ''', SINGLE_BLOB) AS FileData)'
-- execute the combined statement
exec(@sql)
The Stored Procedure is called through a MFC statement and is executing nicely when the passing parameters are ANSI, i.e. English letters. The problem arises when the user selects a file with file name made up of Unicode letters like "Ένα Δείγμα.mp4" (definitely looks Greeks to me) where the exemption I get is like below:
Cannot bulk load because the file "D:??? ??????.mp4" could not be opened. Operating system error code 123(The filename, directory name, or volume label syntax is incorrect.).
Apparently the ODBC driver is passing gibberish or something.
I have tried to debug/execute the same stored procedure using the same parameters using MSSM Studio and there is no problem.
How can I pass parameters in a stored procedure?