Solved

Migration to MSSQL - Concatenation in Update Statement

Posted on 2012-04-05
3
352 Views
Last Modified: 2012-04-10
I am migrating a database from access to MSSQL, and updating the website coding as I go. I had an update statement as follows:

UPDATE Customers SET cCredit = cCredit+"&Request.form("credit")&", cCreditNotes = '"&DATE()&"-"&Request.form("credit")&"-"&why&";"&cCreditNotes WHERE cId = "& Request.form("cust") &"

Open in new window


The update of cCreditNotes is supposed to add the entered values to the beginning of the existing data for that field. However, I get the following error:

The data types varchar and nvarchar(max) are incompatible in the '&' operator.

Open in new window


How can I achieve the same result as I had with Access in MSSQL?

Thank you
0
Comment
Question by:stressfreewebs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 2

Assisted Solution

by:davidi1
davidi1 earned 500 total points
ID: 37810414
have u tried using + instead of &?
0
 

Accepted Solution

by:
stressfreewebs earned 0 total points
ID: 37810457
Hi David,

I tried +, but found it didn't work when the value in the column was null.

However, I've got around that by repeating the same statement twice, once with a where xxx is null, and once with a where xxx is not null. The null one doesn't use +, the is not null one does.

This seems to do the trick, so thanks for the pointer to using the + sign

Dan
0
 

Author Closing Comment

by:stressfreewebs
ID: 37826737
Thanks to the pointer I was able to work a full solution
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

759 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