How do you insert blog data into a database?

  • I've got an assignment, one that I've never done before. Even though I've got over 15 years experience working with SQL Server, I've never worked with a column that's defined as a binary data type. (In the past if ever we had to include a photo we stored a link to the JPG/BMP/PNG/whatever into a column, but never actually inserted or updated a column with binary data.

    But now I've got to do that. So how do you put data into a column defined as BINARY(4096)?

    Kindest Regards, Rod Connect with me on LinkedIn.

  • Take a look at this https://msdn.microsoft.com/en-us/library/ms188362.aspx , it might help!

    Cheers ..

  • Thank you, this sort of helps. But the link you provided didn't give an example of how to insert a blob data item into a column defined as binary(n).

    Actually now I've got another question. Someone else here at work has defined the table. They made the column BINARY(4096). Since it's not VARBINARY, but BINARY, what happens if someone puts in an image that is only 2K in size? Given the current definition must it be the case that anything inserting and updated into the table must be precisely 4K?

    Kindest Regards, Rod Connect with me on LinkedIn.

  • Hi here's an example of loading a pdf into a varbinary

    create table pdf

    (

    ID INT IDENTITY(1,1),

    pdfFile varbinary(max),

    CONSTRAINT PK_ID PRIMARY KEY CLUSTERED

    (

    ID ASC

    )

    )

    INSERT INTO pdf(pdfFile)

    SELECT * FROM OPENROWSET(BULK 'D:\Simon.pdf', SINGLE_BLOB)

    Regards

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply