从相对路径批量插入图像
我想知道是否有人可以帮我解决这个小问题。我有以下插入语句:
insert into symbol (sy_id, sy_fg_color, sy_bg_color, sy_icon)
select 302, 0, 16245177, sy_icon = (select * from openrowset(bulk 'K:\mypath\icons\myicon.png', single_blob) as image)
是否可以以任何方式使路径相对?我正在使用 TFS 来部署数据库,因此如果无法使其与 T-SQL 相关,也许可以通过 TFS/Visual Studio 部署的一些帮助来完成?
I wonder if some can help me out with this little problem. I have the following insert statement:
insert into symbol (sy_id, sy_fg_color, sy_bg_color, sy_icon)
select 302, 0, 16245177, sy_icon = (select * from openrowset(bulk 'K:\mypath\icons\myicon.png', single_blob) as image)
Is it possible to make the path relative in any way? I'm using TFS to deploy the database, so if it's not possible to make it relative with T-SQL, maybe it can be done with a little help from TFS/Visual Studio deploy?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 T-SQL 使用
OPENROWSET
命令插入到varbinary(max)
字段中。请注意,本例中的文件路径是相对于目标 SQL 服务器的,而不是相对于运行此命令的客户端。
本质上,有两种使用 TSQL SELECT BLOB 的方法:
以及:
然后您可以通过执行 INSERT SELECT... 或 UPDATE SELECT ... 来使用它来 INSERT。
查看更多 此处。
You can insert into a
varbinary(max)
field using T-SQL using theOPENROWSET
commmand.Note that the file path in this case is relative to the targeted SQL server and not your client running this command.
Essentially, there are two ways to SELECT a BLOB with TSQL:
As well as:
You can then use this to INSERT by doing an INSERT SELECT... or an UPDATE SELECT ...
See more here.