?
Solved

append to an an nvarchar in MSSQL

Posted on 2009-04-29
4
Medium Priority
?
588 Views
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.
0
Comment
Question by:Dave_Angel_Portsmouth
4 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 2000 total points
ID: 24261590
Hello Dave_Angel_Portsmouth,

use '+' for string catenation

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


Regards,

aneeshattingal
0
 
LVL 60

Expert Comment

by:chapmandew
ID: 24261595
use + instead of &
0
 
LVL 2

Author Closing Comment

by:Dave_Angel_Portsmouth
ID: 31575985
NIce.

Thanks very much.
0
 
LVL 31

Expert Comment

by:RiteshShah
ID: 24261647
actually & from vb to concate string, SQL should have +
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Integration Management Part 2
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

850 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