SQL Server Performance

Error converting nvarchar to varbinary

Discussion in 'General DBA Questions' started by arratialino, Jan 18, 2006.

  1. arratialino New Member

    Disallowed implicit conversion from data type nvarchar to data type varbinary, table 'Development.dbo.Table', column 'Password'. Use the CONVERT function to run this query.<br /><br />I am new to the forum, so I hope I am using the correct format and all.<br /><br />Trying to build an Stored Procedure that will compare a password and verify if it has changed, then do the update to the table, in order to compare, I receive as a parameter the password as nvarchar, I am converting the binary value of the table into nvarchar, comparing it, and if different, then trying to do the update on the table and I get the posted message. <br /><br />Can somebody help?? I am running out of ideas... <img src='/community/emoticons/emotion-1.gif' alt=':)' /><br /><br />By the way, it is SQL Server 2000, forgot to mention it.<br /><br />
  2. Luis Martin Moderator

    Could you post the code?


    Luis Martin
    Moderator
    SQL-Server-Performance.com

    Although nature commences with reason and ends in experience it is necessary for us to do the opposite, that is to commence with experience and from this to proceed to investigate the reason.
    Leonardo Da Vinci

    Nunca esperes el reconocimiento de tus hijos, eso ocurrirá luego de tu muerte


    All postings are provided “AS IS” with no warranties for accuracy.



  3. arratialino New Member

    You mean the whole Stored Procedure? It is quite long...
    Can I post something that big??
  4. Madhivanan Moderator

    You cant directly compare them. Use convert function

    If convert(nvarchar(100),varbinarycol)=nvarcharCol
    --

    Madhivanan

    Failing to plan is Planning to fail
  5. FrankKalis Moderator

  6. arratialino New Member

    This is the deal... I retrieve from the database the binary value, convert it into nvarchar and send it to the application for display, the value can be changed in the app, therefore, when the change is complete, the app sends the new value back as nvarchar.

    At that point, through the stored proc, I retrieve again the old value, convert it to nvarchar and compare the two values, if different, I proceed to do the update, then is when I am getting the error.

    Actually I have not been able to even create the stored proc, since it returns me the error listed above when I try to create it.

    IF @09 <> @Old09
    BEGIN
    UPDATEPlayers
    SETPinWeb = @09
    WHEREPlayerID = @ID
    SELECT@Error = @@ERROR
    IF @Error <> 0
    BEGIN
    ROLLBACK TRANSACTION
    SELECT 2AS Error
    RETURN
    END
    ELSE
    This is the piece of the code that is giving me a MAJOR HEADACHE!
    Thanks guys...
  7. rcmuzzy New Member

    Can you help me convert the following to allow me to post to a binary field in sql server from access the first 8 fields are primary keys
    SELECT "WORKORDER_TYPE","WORKORDER_BASE_ID"
    ,"WORKORDER_LOT_ID"
    ,"WORKORDER_SPLIT_ID"
    ,"WORKORDER_SUB_ID"
    ,"OPERATION_SEQ_NO"
    ,"PIECE_NO"
    ,"TYPE"
    ,CASE
    (UNICODE(CAST(CAST("BITS" AS VARBINARY(4000)) AS NVARCHAR(4000))) - ASCII(LEFT(CAST("BITS" AS VARBINARY(4000)),1
    ))) WHEN 0 THEN CAST(CAST("BITS" AS VARBINARY(8000)) AS NVARCHAR(4000)) ELSE CAST(CAST("BITS" AS VARBINARY(8000)) AS VARCHAR(8000)) END AS "BITS","BITS_LENGTH"FROM REQUIREMENT_BINARY
    WHERE "TYPE" = 'D'
  8. FrankKalis Moderator

    Sorry, but you've lost me with all these CASTs. What is the purpose of this whole CASE expression?

Share This Page