Solved

Sql Server udpate with select query

Posted on 2011-09-28
2
208 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
2 Comments
 
LVL 39

Accepted Solution

by:
BrandonGalderisi earned 500 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

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 …
Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
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.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 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

11 Experts available now in Live!

Get 1:1 Help Now