Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

case help

Status
Not open for further replies.

futbwal15

IS-IT--Management
Jan 12, 2007
38
0
0
US
need some help with coding...i want to be able to search my table first off...i want to be able to update the table, ONLY if the record IS NOT ALREADY THERE. i dont know if a CASE command will work here or not....please help.
 
You can't UPDATE the table if the records are not there, but you could INSERT them.
Can you post some data and want you want to do? I think this is not a difficult job, but who knows :)

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
How about a TRIGGER using FOR INSERT? Look it up in the BOL (Books OnLine) that comes with SQL Server.

You can code it to look for the row and if it doesn't exist, insert it. If it does exist...do something else.

Again, your best bet is to look up the syntax in the BOL.

-SQLBill

Posting advice: FAQ481-4875
 
INSERT INTO "ripedata" (matteridstring)
select distinct
f.matteridstring
from contacts c, parties p, fileinfo f, listbox l, events e
where
c.contactid = p.contactid and
f.fileno = p.fileno and
f.filetype = l.id and
e.fileno = f.fileno and
f.isactive = 1 and
e.title like '%Converted to LL%' and
e.date >= '01/01/2007' and
f.matteridstring is not null






this is what i thought would work but isnt quite it....i did some research and thought maybe a CASE command might work somehow, but im not sure....

 
And you don't want to insert existing [matteridstring] in ripedata? Right?

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
correct, dont want to insert existing data....any ideas?
 
I'm not sure I understand your question correctly, but why don't you just add to your WHERE clause:

AND f.matteridstring NOT IN (SELECT DISTINCT matteridstring FROM ripedata)
 
Can you give us some sample data to work with? Show us the sample data as though it is the table(s) and then show us what results you want to get.

-SQLBill

Posting advice: FAQ481-4875
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top