Code:
CREATE TABLE #files(filename varchar(255)) INSERT INTO #files EXEC master..xp_cmdshell 'dir C:\Inetpub\[URL unfurl="true"]wwwroot\website\html\images\productSpecific\large1\*.jpg[/URL] /b'
UPDATE P
SET [image] = 1
FROM tblProduct P INNER JOIN
tblCompany C ON P.company = C.ID INNER JOIN
#files F ON F.filename = C.name + ' ' + CONVERT(varchar(6), P.productCode) + '.jpg'
Right now I am using this script to basically put a 1 in the field for the product where an image exists in the folder on the server. However it does not work for all the images and I have narrowed it down to this:
WORKS ON
CompanyName 11134.jpg
(product code in table is 11134)
DOES NOT WORK ON
CompanyName 21 432 P.jpg
(product code in table is 21-432-P)
So it looks like it does not like the dashes and there needs to be some sort of conversion. I did not write this script so I am not sure on what needs to change. Any help will be greatly appreciated.
Thank you,
Russ