这些是我发现插入二进制数据(使用varbinary)的查询,这是完美的工作
CREATE TABLE Employees
(
Id int,
Name varchar(50) not null,
Photo varbinary(max) not null
)
INSERT INTO Employees (Id, Name, Photo)
SELECT 10, 'John', BulkColumn from Openrowset( Bulk 'C:photo.bmp', Single_Blob) as EmployeePicture
但是如果表employee有如下列:
CREATE TABLE Employees
(
Id int,
Photo varbinary(max) not null,
Name varchar(50) not null
)
[Photo column is second over here!])
我试图操纵插入查询,但没有帮助!!
使用
INSERT INTO Employees
SELECT 10, BulkColumn AS EmployeePicture, 'John'
FROM OPENROWSET( BULK 'C:photo.bmp', Single_Blob) bc
或
INSERT INTO Employees
SELECT 10,
(SELECT BulkColumn AS EmployeePicture FROM OPENROWSET( BULK 'C:photo.bmp', Single_Blob) bc),
'John'
我猜你可能在尝试这样做
INSERT INTO Employees
SELECT 10,
BulkColumn AS EmployeePicture FROM OPENROWSET( BULK 'C:photo.bmp', Single_Blob),
'John'