Posted by ZeldorBlat on 10/01/76 11:38
Water Cooler v2 wrote:
> There are two datatypes for storing binary data type in the SQL Server:
>
> 1. binary - for fixed length binary data
> 2. varbinary - for variable length data
>
> My question is: how is data inserted into them? Do they have any
> delimiters that go into the insert statement like strings and datetimes
> have? What format (hex/decimal?) do they accept data in? Can you please
> give me an insert statement example?
Apparently Celko forgot about the part where you answer the question.
I've always done it by encoding it in hex first. Then you can do
something like this:
insert myTable (myBinaryColumn) values (0x8d7e6a5d4b3e2e1f)
Just put the 0x before whatever hex value you come up with. The
difference between the two is the same as the difference between char
and varchar. In general, if the values in that column are either short
or all roughly (or exactly) the same length, use binary. Otherwise,
use varbinary.
Navigation:
[Reply to this message]
|