all groups > sql server data warehouse > january 2005 >
You're in the

sql server data warehouse

group:

Insert Binary Data with APOSTROPHE


Re: Insert Binary Data with APOSTROPHE Dan Guzman
1/28/2005 7:38:25 AM
sql server data warehouse:
To add to Tibor's response, consider passing the value as a properly typed
parameter you application program:

CREATE PROCEDURE InsertBinaryTest
@BinaryData binary(10)
AS
INSERT INTO binarytest VALUES(@BinaryData)
GO

EXEC InsertBinaryTest @BinaryData = 0x6165736467413F760000

--
Hope this helps.

Dan Guzman
SQL Server MVP

[quoted text, click to view]

Re: Insert Binary Data with APOSTROPHE Francesco Anti
1/28/2005 11:21:53 AM
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

[quoted text, click to view]

Re: Insert Binary Data with APOSTROPHE Tibor Karaszi
1/28/2005 12:22:38 PM
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/


[quoted text, click to view]

Insert Binary Data with APOSTROPHE Uma
1/28/2005 2:15:15 PM
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.

Re: Insert Binary Data with APOSTROPHE Uma
1/28/2005 4:52:28 PM
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



[quoted text, click to view]

Re: Insert Binary Data with APOSTROPHE Lien Coolman
1/28/2005 5:21:32 PM
[quoted text, click to view]
on 28-01-2005 09:45:

[quoted text, click to view]
ge ziet ne sukel ahhahahahaha
Re: Insert Binary Data with APOSTROPHE Uma
1/29/2005 1:26:27 PM

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...
[quoted text, click to view]

Re: Insert Binary Data with APOSTROPHE Tibor Karaszi
1/31/2005 6:41:30 PM
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
(double it).

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/


[quoted text, click to view]

AddThis Social Bookmark Button