I'm using OPENROWSET(BULK ...) to insert the contents of a file into my table. The problem is that I also need to specify the value of another column in the same INSERT statement.
我正在使用OPENROWSET(BULK ...)将文件的内容插入到我的表中。问题是我还需要在同一个INSERT语句中指定另一列的值。
I have something like this:
我有这样的事情:
INSERT INTO MyTable
SELECT *
FROM OPENROWSET(BULK 'c:\foo.bin', SINGLE_BLOB)
I'm sure there's a way to also specify the value of a different column here, but I don't know how.
我确定有一种方法可以在这里指定不同列的值,但我不知道如何。
1 个解决方案
#1
4
Found it, it was in the link posted by astandar, but under example D:
发现它,它是在astandar发布的链接中,但在示例D下:
INSERT INTO MyTable (col1, col2)
SELECT 'foo' AS col1, *
FROM OPENROWSET(BULK N'c:\foo.bin', SINGLE_BLOB) AS col2
#1
4
Found it, it was in the link posted by astandar, but under example D:
发现它,它是在astandar发布的链接中,但在示例D下:
INSERT INTO MyTable (col1, col2)
SELECT 'foo' AS col1, *
FROM OPENROWSET(BULK N'c:\foo.bin', SINGLE_BLOB) AS col2