且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用SQL Server Management Studio将Blob插入数据库

更新时间:2022-02-20 22:37:56

您可以在SQL Server Management Studio中使用T-SQL(尤其是使用OPENROWSET命令)将其插入varbinary(max)字段中.

You can insert into a varbinary(max) field using T-SQL within SQL Server Management Studio and in particular using the OPENROWSET commmand.

例如:

INSERT Production.ProductPhoto 
(
    ThumbnailPhoto, 
    ThumbnailPhotoFilePath, 
    LargePhoto, 
    LargePhotoFilePath
)
SELECT ThumbnailPhoto.*, null, null, N'tricycle_pink.gif'
FROM OPENROWSET 
    (BULK 'c:\images\tricycle.jpg', SINGLE_BLOB) ThumbnailPhoto

请参阅以下文档,以获取良好的示例/演练

Take a look at the following documentation for a good example/walkthrough

使用大值类型

请注意,在这种情况下,文件路径是相对于目标SQL Server的,而不是相对于运行此命令的客户端的.

Note that the file path in this case is relative to the targeted SQL server and not your client running this command.