I'm not sure what you are saying here. In your example, you express the text information as a
string, then CAST it to binary. But as you express it as a string, you need to follow the rules for
string handling. Those rules are that you enclose the string within single-quotes. And if you want
to express a single-quote inside the string, you escape that single-quote with another single-quote
"Uma" <uma@cspl.com> wrote in message news:uph$g00BFHA.3528@tk2msftngp13.phx.gbl...
>
> Actually I need to store the Apostrophe in the binary data itself. What can
> I do if so?
> We can use the method as '''' (four apostrophe) for inserting a single
> apostrophe, Is any other flexible method available? I won't check the
> Apostrophe present in the binary data or not, when I am calling the Stored
> Procedure in my C program.
>
> "Tibor Karaszi" <tibor_please.no.email_karaszi@hotmail.nomail.com> wrote in
> message news:e2e6quSBFHA.3940@TK2MSFTNGP09.phx.gbl...
>> Since you express the data as a string before the cast, do the same as
> usual, double each
>> single-quote:
>>
>> insert into binarytest values(cast('aesdg''A?v' as binary(10)))
>>
>>
>> --
>> Tibor Karaszi, SQL Server MVP
>>
http://www.karaszi.com/sqlserver/default.asp >>
http://www.solidqualitylearning.com/ >>
http://www.sqlug.se/ >>
>>
>> "Uma" <uma@cspl.com> wrote in message
> news:OxDwgrSBFHA.136@TK2MSFTNGP14.phx.gbl...
>> > The following queries are working fine:
>> >
>> > create table binarytest(binfield binary(100))
>> >
>> > 1.insert into binarytest values(cast('123' as binary(10)))
>> > 2.insert into binarytest values(cast(123 as binary(10)))
>> > 3.insert into binarytest values(cast('aesdgA?v' as binary(10)))
>> >
>> > What should be done if I want to execute the following query?
>> >
>> > insert into binarytest values(cast(aesdg'A?v as binary(10)))
>> >
>> > Binary data : aesdg'A?v
>> >
>> > For apostrophe, the hexadecimal value is 27, decimal value is 39
>> >
>> > This statement is required since we are actually inserting into this
> table
>> > through an stored procedure which we are calling in C program. In C
> program
>> > we are sending binary data, which may also contain apostrohpe('),
> comma(,),
>> > space( ) and many more characters.
>> >
>> > Regards,
>> > Shahul
>> >
>> >
>> >
>> > "Francesco Anti" <fanti @ sicosbt.it> wrote in message
>> > news:OUWZyMSBFHA.2192@TK2MSFTNGP14.phx.gbl...
>> >> binary data type accepts only hexadecimal values....how can you obtain
> an
>> >> apostrophe from an hexadecimal representation of a bit string??
>> >> Can you post some example of your insert statement?
>> >>
>> >> Francesco Anti
>> >>
>> >> "Uma" <uma@cspl.com> wrote in message
>> >> news:us32pTRBFHA.2180@TK2MSFTNGP10.phx.gbl...
>> >> > Hi pals,
>> >> >
>> >> > I am trying to insert binary data in to a field(data type:binary) of
> a
>> >> > table. Facing a problem with inserting if the binary data contains
>> >> > APOSTROPHE ( ' ). SQL Server expects another APOSTROPHE to end the
>> > data.
>> >> > How could I insert that type of data into a binary field ? Could you
>> >> please
>> >> > guide me?
>> >> >
>> >> > regards,
>> >> > Shahul.
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>>
>
>