append to an an nvarchar in MSSQL

Posted on 2009-04-29
Last Modified: 2012-05-06
How do I append an nvarchar with a leading character.
Someone has imported a load of telephone numbers into our crm system and forgot to make sure that the feild was a text feild, so they got convereted to numbers and the leading zeros were removed.

Though it would just be a simple case of...

UPDATE dbo.accountbase
SET [telephone1] = '0' & [telephone1]
Where left([telephone1],1) = '1'

But I get

Msg 402, Level 16, State 1, Line 2
The data types varchar and nvarchar are incompatible in the boolean AND operator.
Question by:Dave_Angel_Portsmouth
    LVL 75

    Accepted Solution

    Hello Dave_Angel_Portsmouth,

    use '+' for string catenation

    UPDATE dbo.accountbase
    SET [telephone1] = '0' + [telephone1]
    Where left([telephone1],1) = '1'


    LVL 60

    Expert Comment

    use + instead of &
    LVL 2

    Author Closing Comment


    Thanks very much.
    LVL 31

    Expert Comment

    actually & from vb to concate string, SQL should have +

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
    How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    732 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

    22 Experts available now in Live!

    Get 1:1 Help Now