home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.ms-sqlserver      Notorious Rube Goldberg contraption      19,505 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 19,081 of 19,505   
   Shelly to Erland Sommarskog   
   Re: Varbinary and nvarchar problem   
   23 Jun 14 16:35:25   
   
   From: sheldonlg@thevillages.net   
      
   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   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca