Thanks a lot guys: there is a beginning of an understanding. Putting it into practice look at the following:
CREATE TABLE #images (files VARCHAR(500) NULL, InsertCMD
AS 'INSERT INTO Renner_Foto (ImageID, ImageName, ImageData ) '
+ ' SELECT ' + LEFT(files, PATINDEX('%[^0-9]%', files) - 1) + ' AS ImageID, '
+ '''' + files + ''' As ImageName, '
+ 'BulkColumn FROM OPENROWSET( Bulk '
+ '''D:\MijnDocumenten\DWCoureurLocaleData\Irfanview_20112011\' + files + ''','
+ ' SINGLE_BLOB) AS BLOB '
The rules are:
the contents of InsertCMD needs to be in single quotes;
the SQL-commands need no further treatment (just single quotes);
the left part don't need quotes because it is a literal;
then the part with '''' + files + ''' As ImageName, ' I don't understand: files is literal but needs double quotes?
the same in relation to the last part: why three quotes (double and a single I assume) before D:\MijnDocumenten\etc. then a single quote and at last again a triple and a single.
The only thing that is understandable is the fact that they come in pairs, so the total amount of quotes is always even. It is the placing that give me problems.
Perhaps someone can give it one further try?
Thanks in advance,