T-SQL: issue with string concat

前端 未结 2 998
醉酒成梦
醉酒成梦 2020-12-18 21:55

I have a set of audio files with names GreenLine1.mp3, GreenLine2.mp3 e.t.c. I\'m going to write them into a table as BLOB (I use MS SQL Server\'08), here\'s my sql request:

2条回答
  •  臣服心动
    2020-12-18 22:51

    This article pointed me in the right direction when I had the same issue with OPENQUERY:

    https://web.archive.org/web/20120724073530/http://consultingblogs.emc.com/jamespipe/archive/2007/06/28/SQL-Server-2005_3A00_-Passing-variables-into-an-OPENQUERY-argument.aspx

    Basically, you can wrap the entire statement in a variable (nvarchar), including the openrowset, and run exec sp_executesql @sql. It gets a little ugly to read around the 's though, because you'll have to escape them with ''.

提交回复
热议问题