Reputation: 462
create table Item(
ID int identity(1000,1) not null,
txt varchar(150),
img varbinary(max),
constraint pk_Item primary key (ID)
)
I can insert an image into this table using the following query:
insert into Item(ID,txt,img)
select 100,'test', BulkColumn from openrowset(bulk N'D:\test.jpeg', single_blob) as image
How can I achieve the same using the values keyword:
insert into Item(ID,txt,img) values (100,'test',[????])
Upvotes: 0
Views: 1993
Reputation: 405
Binary values have a 0x{hexdecimal byte sequence} prefix.
insert into Item(ID,txt,img)
values (100,'test',0x0123456789ABCDEF)
It might be helpful to just query a field that already has binary value to see what it looks like:
select img from Item
Upvotes: 0
Reputation: 93724
Not sure why you want to insert with values keyword when you already have alternative. Try this
insert into Item(ID,txt,img)
values (100,'test',(select BulkColumn from openrowset(bulk N'D:\test.jpeg', single_blob) cs))
Upvotes: 3