MSDE SQL Update Stored Procedure Syntax

  • Thread starter Thread starter Admin
  • Start date Start date
A

Admin

I have 2 tables, table A and B. Table A has the following fields; Phone
(nvchar), Fname (nvchar), Lname (nvchar), DNC (bit). Table B has one field
PhoneNo (nvchar). I would like to update the field DNC to True if the values
Phone in Table A = PhoneNo in Table B.

I tried this syntax but it never updated:

UPDATE dbo.A
SET DNC = 1
WHERE (Phone = 'SELECT MAX dbo.B.PhoneNo FROM dbo.B')

These tables have over 100K records and I would like to make sure it runs
thru and checks every single record not just the first 10000
 
Admin said:
I have 2 tables, table A and B. Table A has the following fields;
Phone (nvchar), Fname (nvchar), Lname (nvchar), DNC (bit). Table B
has one field PhoneNo (nvchar). I would like to update the field DNC
to True if the values Phone in Table A = PhoneNo in Table B.

I tried this syntax but it never updated:

UPDATE dbo.A
SET DNC = 1
WHERE (Phone = 'SELECT MAX dbo.B.PhoneNo FROM dbo.B')

These tables have over 100K records and I would like to make sure it
runs thru and checks every single record not just the first 10000

I'm not sure I understand, because your text description of what you
want to accomplish and your SQL don't seem to correspond. From your
description, I'd have thought you would be using something like this:

UPDATE dbo.A
SET DNC = 1
FROM dbo.A INNER JOIN dbo.B ON dbo.A.Phone = dbo.B.PhoneNo
 
Back
Top