The data types nvarchar and uniqueidentifier are incompatible in the add operator.

Posted on 2007-08-07
Last Modified: 2013-11-05

How do i use a variable of type uniqueidentifier in a string concatentation

Here is my line

SET @filter = @filter + '  J.EngineerID = ''' + @engineerID  + ''''
but i get this error
The data types nvarchar and uniqueidentifier are incompatible in the add operator.

Question by:andieje
    LVL 75

    Expert Comment

    by:Aneesh Retnakaran
    u need to explicitly convert that unid variable

    CAST(unid as varchar)
    LVL 75

    Accepted Solution

    sorry Convert as nVarchar
    CAST(unidColumn as nVarchar )

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    I recently came across an interesting Question In EE ( and was puzzled about how to achieve that using SSIS out of the box tasks, which was i…
    This is my first ever Article on EE or elsewhere; therefore, please bear with me if I have some discrepancies in my writing. I read many articles and questions related to "how to pass values to SSIS packages at run-time?"  Hence, this common ques…
    Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
    Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now