Solved

Check the value of a record.

Posted on 2007-11-20
3
305 Views
Last Modified: 2010-03-20
HI. Without writing a cursor, i would like to check the value in a table, and if the zip = 0 then i dont' want to do the following: however, if it does exist, then i want to go thru this process. thee problem with a cursor, if these tables are over a million rows, it will take to long.

the table i want to check first is qa_mrsi_data and the column is zip

update qa_address
set        qa_address1 = b.addr,
      qa_address_city = b.city,
      qa_address_state = b.state,
      qa_address_zip =b.zip
from qa_mrsi_data b
inner join qa_address on
qa_address.qa_name_sid = b.sid
where [q3.0] > 0 or [q3.1]>0
0
Comment
Question by:basile
  • 2
3 Comments
 
LVL 18

Expert Comment

by:Yveau
ID: 20322491
... all you need to do is adding a line saying something similar to:
    and b.zip != 0

I think ...

Hope this helps ...
0
 
LVL 30

Expert Comment

by:nmcdermaid
ID: 20337057
Is zip in the same table or a different table?

If in the same table:

update qa_address
set        qa_address1 = b.addr,
      qa_address_city = b.city,
      qa_address_state = b.state,
      qa_address_zip =b.zip
from qa_mrsi_data b
inner join qa_address on
qa_address.qa_name_sid = b.sid
where [q3.0] > 0 or [q3.1]>0
and zip <> 0



If its in a different table, you juse join to it. Is there a column in both tables that can be used to match?
0
 
LVL 30

Accepted Solution

by:
nmcdermaid earned 500 total points
ID: 20337058
pdate qa_address
set        qa_address1 = b.addr,
      qa_address_city = b.city,
      qa_address_state = b.state,
      qa_address_zip =b.zip
from qa_mrsi_data b
inner join qa_address on
qa_address.qa_name_sid = b.sid
where [q3.0] > 0 or [q3.1]>0
and b.zip <> 0
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 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

13 Experts available now in Live!

Get 1:1 Help Now