1

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.

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 Answer 1

6

Found it, it was in the link posted by astandar, but under example D:

INSERT INTO MyTable (col1, col2)
SELECT 'foo' AS col1, *
FROM OPENROWSET(BULK N'c:\foo.bin', SINGLE_BLOB) AS col2
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.