rdshultz (rdshultz@nooter.com) writes:
[quoted text, click to view] > I'm a complete newbie. Need to insert a Company logo into a database
> column to use later on in a check printing application. Read how to
> insert the pointer instead of the object into the column. Below is
> what I did:
>
> SET QUOTED_IDENTIFIER OFF
> GO
> INSERT INTO BankInfo
> (CoLogo) VALUES(0xFFFFFFFF)
>
> ***Then I did this****
>
> DECLARE @Pointer_Value varbinary(16)
> Select @Pointer_Value = TEXTPTR(CoLogo)
> FROM BankInfo
> WHERE CMCo = '91'
> WRITETEXT BankInfo.CoLogo @Pointer_Value
> "\\192.31.82.77\Data\CheckImages\WyattLogo.jpg"
>
> ****This was straight out of a book and it seemed to work it gave me a
> message that it was successful and when I view the data in the column
> I can see the pointer
> 0x453A5C436865636B496D616765735C57796174744C6F676F2E6A7067*****
Alas, it is not that easy. What you have there, is some sort of
binary representation of the URL itselt. (Actually, it is not. This
is from your attempt to use C:\WyattLogo.jpg.) SQL Server is not going out
to access the web or your disk to read the JPEG for you. You need to say:
WRITETEXT BankInfo.CoLogo @Pointer_Value
0xFFD8FFE1D8454578...
Where the hex string is contents of the file itself. The "pointer" in
this context is a pointer with SQL Server, to the special area where the
value for this image column are stored.
So how would you do this in practice? Most commonly, I think people
use the ADO method AddChunk write a program that reads the binary
file and sends down in pieces. But you could of course also write a
program that constructs the entire SQL batch with hexstring and all.
(If you use AddChunk I don't think you need to convert to hexstring.)
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server SP3 at