Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Sql Server udpate with select query

Posted on 2011-09-28
2
Medium Priority
?
223 Views
Last Modified: 2012-05-12
Hi,

I have the following statement and am getting an error.  I can see why there is an error, but what is the work around.  

So essentially I need to set check =1 when customernumber=realmid and the barcode =the barcode from another table...

Thanks

UPDATE Customer_Info_Barcode_Assay
SET Check1 = 1
WHERE CustomerNumber=@RealmId and Barcode=(SELECT IntuitQboInvoiceId
                                                               FROM dbo.Intuit_Staging_Invoice_w_ID
                                                               GROUP BY RealmId, IntuitQboInvoiceId)
0
Comment
Question by:joygomez
[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 Comments
 
LVL 39

Accepted Solution

by:
BrandonGalderisi earned 2000 total points
ID: 36717616
You have nothing to tie the subselect to the parent.  Try something like below.  Try below

UPDATE BA
SET Check1 = 1
from Customer_Info_Barcode_Assay BA
WHERE CustomerNumber=@RealmId
  and exists (SELECT ii.IntuitQboInvoiceId
                         FROM dbo.Intuit_Staging_Invoice_w_ID ii
                         where ii.RealmId = ba.CustomerNumber
                            and ii.IntuitOboInvoiceId = BA.Barcode)
0
 

Author Comment

by:joygomez
ID: 36717681
Great... works good...
Thanks.
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

After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

618 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