Insert Image

Posted on 2012-08-29
Last Modified: 2012-08-30

I have column (binary) in KPIimg table, I need to insert image into KPIimg

 Insert [KPIimg] (rate,[img])
 Values (1,(Select  *  from Openrowset( Bulk 'D:\PIC\green.jpg', Single_Blob) as KPI))

I got error:
Msg 8152, Level 16, State 10, Line 1
String or binary data would be truncated.
The statement has been terminated.
Question by:samprg
    LVL 9

    Expert Comment

    Try this one

    INSERT INTO [KPIimg] (rate,[img])  
    SELECT 1, BulkColumn
    FROM Openrowset( Bulk 'D:\PIC\green.jpg', Single_Blob) as KPI

    Author Comment

    I get same error, I am useing sql 2012
    LVL 75

    Accepted Solution

    Did you chekc the length of that VARBINARY column, make sure that it is VARBINARY(MAX)

    Author Closing Comment

    Excellent, it was binary(50)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Introduction In my previous article ( I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
    Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
    This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
    Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now