Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 delete query

Author  Topic 

maya_zakry
Constraint Violating Yak Guru

379 Posts

Posted - 2007-05-25 : 03:59:52
hi all,
how do i perform this query?

DELETE FROM tblStkAdjDetail
WHERE (SELECT ItemStorageID FROM tblStkAdjDetail WHERE Status='NEW'
AND ItemStorageID NOT IN (SELECT ItemStorageId FROM tblTempTableForRecvPacking) )


~~~Focus on problem, not solution ¯\(º_o)/¯ ~~~

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-05-25 : 04:09:32
[code]Delete t1
from tblStkAdjDetail t1 LEFT JOIN tblTempTableForRecvPacking t2
on t1.ItemStorageID = t2.ItemStorageID
Where t1.Status='NEW' and t2.ItemStorageID is NULL[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

maya_zakry
Constraint Violating Yak Guru

379 Posts

Posted - 2007-05-25 : 04:11:02
oppss
i forgot to assign the where clause :P, this worked :-

DELETE FROM tblstkadjdetail
WHERE ItemStorageID= (
SELECT ItemStorageID FROM tblstkadjdetail WHERE status='NEW' AND jobid=@JobID
AND ItemStorageID NOT IN (SELECT ItemStorageID FROM tblTemptableForrecvpacking WHERE jobid='AJ25507002')
)


ps : tan, u were very fast.. i was just about to edit my post..
btw.. i used to ty that left join.. but there are times that in the left join table, no such @jobid at all, therefore it didt return null for column itemstorageid.. im not sure if this true.. maybe im wrong

~~~Focus on problem, not solution ¯\(º_o)/¯ ~~~
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-05-25 : 04:28:21
quote:
ps : tan, u were very fast.. i was just about to edit my post..

Yeah, I am so fast that you can't see me



KH

Go to Top of Page

maya_zakry
Constraint Violating Yak Guru

379 Posts

Posted - 2007-05-25 : 04:34:02
why sometimes your country malasysia/singapore??? where are u?

~~~Focus on problem, not solution ¯\(º_o)/¯ ~~~
Go to Top of Page

maya_zakry
Constraint Violating Yak Guru

379 Posts

Posted - 2007-05-25 : 04:34:49
or maybe u cross m'sia - s'pore every week? hahahah

~~~Focus on problem, not solution ¯\(º_o)/¯ ~~~
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-05-25 : 04:36:46
not every week. Once about every 2 or 3 weeks. Currently implementing a project in M'sia so have to travel up there often


KH

Go to Top of Page

maya_zakry
Constraint Violating Yak Guru

379 Posts

Posted - 2007-05-25 : 04:42:25
oic.. which part? kl? jb? im stuck im penang.. hahahahhahah... not much travel... :)

~~~Focus on problem, not solution ¯\(º_o)/¯ ~~~
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-05-25 : 04:48:18
Normally I will be in Subang Jaya.


KH

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-05-26 : 03:26:10
quote:
Originally posted by khtan

not every week. Once about every 2 or 3 weeks. Currently implementing a project in M'sia so have to travel up there often


KH




Swapping countries

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-05-26 : 06:21:39



KH

Go to Top of Page
   

- Advertisement -