0

I have db table Person which has columns like

Id | Name | Dob | ....

now I added one more column CompanyLogo of type varbinary(MAX) which will is now null. Since I have more than 1000 records in Person table I want to insert on the fly using sql statement some default image for CompanyLogo. Later trough ui this image wil be changed for each person, but that's not the scope of this question.

I tried with code

@"begin
     UPDATE Person SET [CompanyLogo] = (SELECT
     CompanyLogo.* from Openrowset(Bulk
     'd:\test.png', Single_Blob) TestCompanyLogo)                    
    end
  "

but I'm getting following exception

System.Data.SqlClient.SqlException: Column name or number of supplied values does not match table definition

1 Answer 1

1

You have error in your query. Try this.

BEGIN
     UPDATE Person 
         SET [CompanyLogo] = (SELECT TestCompanyLogo.* 
                              FROM OPENROWSET(BULK 'd:\test.png', SINGLE_BLOB) TestCompanyLogo)                    
END
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.