I got this error message when I executed the query.
Msg 105, Level 15, State 1, Line 1
Unclosed quotation mark after the character string ''Msg 102, Level 15, State 1, Line 1
Incorrect syntax near ''
My code:
DECLARE @imgLogo VARCHAR(50)
DECLARE @savPicture VARBINARY(MAX)
DECLARE @strPerson VARCHAR(50) = 'Max Verstappen'
SET @imgLogo = 'SET @SavPicture = (SELECT * FROM OPENROWSET (BULK N''C:\Program Files\Microsoft SQL Server\140\Couriers\ + TRIM (cast('+ @strPerson + '''as char(30))) + .jpg'
EXEC (@imgLogo)
Can someone help me out?
@basePath = N'C:\Program Files\Microsoft SQL Server\140\Couriers\'
,@imageName = TRIM (cast('''+ @strPersoon + '''as char(30))) + .jpg
and then you'll have something like `SET @imgLogo = 'SET @SavPicture= (SELECT * FROM OPENROWSET (BULK @basePath + @imageName))'. Most probably the quotes are not correct here but this approach is easier to isolate the problem. – Leron_says_get_back_MonicaPRINT @imgLogo
before actually executing it? – Eric