Created
November 2, 2021 09:49
-
-
Save davidsheardown/0fab35746918f8aafd37113bbfa8924c to your computer and use it in GitHub Desktop.
Add image to SQL encoded it Base64
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE PROCEDURE [dbo].[sp_add_image_to_SQL] | |
@ImageId int, | |
@ImageFilePath nvarchar(255) | |
AS | |
BEGIN | |
SET NOCOUNT ON; | |
DECLARE @sql_string nvarchar(max) = | |
N'UPDATE tbl_ext_product_images | |
SET [Image] = (SELECT BulkColumn | |
FROM Openrowset(Bulk ' + quotename(@ImageFilePath,nchar(39)) + ', Single_Blob) ImageData) | |
WHERE Id = @ImageId'; | |
EXECUTE sp_executesql @sql_string, N'@ImageId bigint', @ImageId | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment