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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delete

Status
Not open for further replies.
Joined
Jun 1, 2006
Messages
58
Location
US
Hi

i have to delete records from a table. The criterion for deletion are specified in the parent table.

here is a part of the stored proc that i have,but it does not work.I am wondering if there is another way of making this work.

delete
from
(select g.*
from shshrssurvey as s,grdshsmaildates as g
where s.id = g.parentid
and
s.datecreated > '2006-04-01') it gives me an incorrent syntax error.

please help.
 
Which table are you trying to delete from?

The general syntax would be...

Code:
Delete [!]g[/!]
from   shshrssurvey as s
       Inner join grdshsmaildates as g
         On  s.id = g.parentid 
         and s.datecreated > '2006-04-01'

This assumes you want to delete records from the [!]g[/!] table (actually the grdshsmaildates) table. If you want to delete from the other table, then change the g to s.

As always, you should change the Delete part to a select part to make sure the proper records will be deleted.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top