Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #1777

Re: Varbinary and nvarchar problem

From Shelly <sheldonlg@thevillages.net>
Newsgroups comp.databases.ms-sqlserver
Subject Re: Varbinary and nvarchar problem
Date 2014-06-23 16:35 -0400
Organization A noiseless patient Spider
Message-ID <loa327$lo5$1@dont-email.me> (permalink)
References (2 earlier) <lnvlt4$nnk$1@dont-email.me> <XnsA352A57E3723Yazorman@127.0.0.1> <lo9b9q$p9g$1@dont-email.me> <lo9dg7$8bf$1@dont-email.me> <XnsA355DB51B5C3CYazorman@127.0.0.1>

Show all headers | View raw


On 6/23/2014 3:33 PM, Erland Sommarskog wrote:
> Shelly (sheldonlg@thevillages.net) writes:
>> I also tried converting each piece int the HASHBYTES to a varchar or to
>> an nvarchar and still got errors in the pieces -- even though the one
>> without any conversions -- the plain HASHBYTES -- worked. I also tried
>> CAST, but still had those errors.
>>
>> Why does
>>
>> CONVERT(VARCHAR(32), something-that-works, 2)
>>
>> fail -- and with a conversion to int?
>>
>
> Because you use it in expression which also includes an integer value,
> (which because of the data-type precedence rules in SQL Server leads to an
> implicit conversion)

The three pieces that make up the content of what is to in the HASHBYTE 
are all varchar strings.  There are no integer values.  For example, one 
record has 'C00001', 'COMERCIAL' and 'S' as the three pieces, so the 
HASHBYTE is of 'C00001COMERCIALS'.  The result of the HASHBYTE is a 
varbinary, but the convert should be doing an explicit conversion of it 
to varchar(32).

>  or you are trying to insert the data into an integer
> column/variable.

This is a select, not and insert, so there is no target table column.

>
> That is all I can say without seeing the rest of the code and the
> table definitions. Well, one more thing: watch out for triggers with
> dynamic SQL.
>

-- 
Shelly

Back to comp.databases.ms-sqlserver | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Varbinary and nvarchar problem Shelly <sheldonlg@thevillages.net> - 2014-06-19 15:00 -0400
  Re: Varbinary and nvarchar problem Erland Sommarskog <esquel@sommarskog.se> - 2014-06-19 23:06 +0200
    Re: Varbinary and nvarchar problem Shelly <sheldonlg@thevillages.net> - 2014-06-19 17:49 -0400
      Re: Varbinary and nvarchar problem Erland Sommarskog <esquel@sommarskog.se> - 2014-06-20 16:16 +0200
        Re: Varbinary and nvarchar problem Shelly <sheldonlg@thevillages.net> - 2014-06-21 09:17 -0400
        Re: Varbinary and nvarchar problem Shelly <sheldonlg@thevillages.net> - 2014-06-23 09:49 -0400
          Re: Varbinary and nvarchar problem Shelly <sheldonlg@thevillages.net> - 2014-06-23 10:27 -0400
            Re: Varbinary and nvarchar problem Erland Sommarskog <esquel@sommarskog.se> - 2014-06-23 21:33 +0200
              Re: Varbinary and nvarchar problem Shelly <sheldonlg@thevillages.net> - 2014-06-23 16:35 -0400
                Re: Varbinary and nvarchar problem Erland Sommarskog <esquel@sommarskog.se> - 2014-06-24 07:19 +0000

csiph-web