Solved

SQL Update Statement

Posted on 2014-03-12
1
391 Views
Last Modified: 2014-03-12
I am trying to update a column by removing 'mail' from the email addresses.  I use this:

Update employees2
Set email = (SELECT REPLACE(email,'mail.xxxx.edu','xxxx.edu')
from employees2);

However, I get this error message:
Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.

How can I fix
0
Comment
Question by:Jack Seaman
1 Comment
 
LVL 22

Accepted Solution

by:
Steve Wales earned 500 total points
ID: 39924352
Just this should work:

Update employees2
Set email = REPLACE(email,'mail.xxxx.edu','xxxx.edu')

You don't need to select the data again.
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

828 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