Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 nvarchar to varbinary conversion: different string

Author  Topic 

bhatnagarp
Starting Member

5 Posts

Posted - 2012-07-20 : 03:35:01
Declare @Token1 nvarchar(255) = '!???Ae??oöi?À?Õ?UV??TL??˜?ÀX0e0?',
@Token2 nvarchar(255) = '!???Ae??oöi?À?Õ?UV??TL??˜?ÀX0e0?',
@TokenBin1 varbinary(2000),
@TokenBin2 varbinary(2000)

Set @TokenBin1 = CONVERT(varbinary(2000), @Token1)
Set @TokenBin2 = CONVERT(varbinary(2000), @Token2)

Select @TokenBin1, @TokenBin2

IF @TokenBin1 = @TokenBin2
Select 1
else
Select 0

these are different strings but still matching.
The difference is at last string character.

sql-programmers
Posting Yak Master

190 Posts

Posted - 2012-07-20 : 04:55:11
We executed above query it's working good.

In the given example value of Variable @Token1 and @Token2 are same. and conversion of varbinary also same.

So result will be 1.

I modified value of @Token2 = '!???Ae??oöi?À?Õ?UV??TL??˜?ÀX0e0'. Then the result is 0.

Then what is your question. pls explain.



SQL Server Programmers and Consultants
http://www.sql-programmers.com/
Go to Top of Page

bhatnagarp
Starting Member

5 Posts

Posted - 2012-07-20 : 05:06:39
Declare @Token1 nvarchar(255) = '!???Ae??oöi?À?Õ?UV??TL??˜?ÀX0e0?',
@Token2 nvarchar(255) = '!???Ae??oöi?À?Õ?UV??TL??˜?ÀX0e0?',
@TokenBin1 varbinary(2000),
@TokenBin2 varbinary(2000)

The contents of @Token1 & Token2 are different and while uploading the values in fourm the last character is replaced with '?'
The actual values are: Not sure if the values will be replaced with '?' again.

Declare @Token1 nvarchar(255) = '!???Ae??oöi?À?Õ?UV??TL??˜?ÀX0e0?',
@Token2 nvarchar(255) = '!???Ae??oöi?À?Õ?UV??TL??˜?ÀX0e0?'
Go to Top of Page

bhatnagarp
Starting Member

5 Posts

Posted - 2012-07-20 : 05:24:13
Hi.. I have sent an email to youngbharath@yahoo.co.in
Looks like the values are properly sent in the email.
Go to Top of Page

sql-programmers
Posting Yak Master

190 Posts

Posted - 2012-07-20 : 05:38:50
SELECT ASCII('?')
SELECT ASCII('?')

ASCII code of the two character are same. I think this is the problem.

check also in your mail.

SQL Server Programmers and Consultants
http://www.sql-programmers.com/
Go to Top of Page

bhatnagarp
Starting Member

5 Posts

Posted - 2012-07-20 : 05:40:30
some special characters are replaced by '?'. I have sent an email to "youngbharath@yahoo.co.in" which contains correct special characters.
Go to Top of Page

bhatnagarp
Starting Member

5 Posts

Posted - 2012-07-20 : 05:43:51
SELECT ASCII('?')
SELECT ASCII('?')

ASCII code of the two character are same. I think this is the problem.

Thats correct. But not sure how to handle this. Because both characters looks different and are different.
Go to Top of Page
   

- Advertisement -