0
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',[????]) 

2 Answers 2

3

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)) 
Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.