Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Erland Sommarskog Newsgroups: comp.databases.ms-sqlserver Subject: Re: Varbinary and nvarchar problem Date: Mon, 23 Jun 2014 21:33:35 +0200 Organization: Erland Sommarskog Lines: 24 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Injection-Info: mx05.eternal-september.org; posting-host="0c412830dbc354c08130c47cfccdbc83"; logging-data="22403"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19dbu+f9uzwIvVHPR2cESb4" User-Agent: Xnews/2006.08.24 Mime-proxy/2.1.c.0 (Win32) Cancel-Lock: sha1:lvve7hhnkzh8ugzG0VAJHUL7fYQ= Xref: csiph.com comp.databases.ms-sqlserver:1776 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) or you are trying to insert the data into an integer column/variable. 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. -- Erland Sommarskog, Stockholm, esquel@sommarskog.se