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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 What does this mean ?

Author  Topic 

indervirsingh
Starting Member

3 Posts

Posted - 2002-12-18 : 04:59:39
Hi,
Recently while working on some stored procedures I came on a query

Delete Sch_Daily
From Sch_Daily S Left Join Pay_Types P On S.Pay_Type_ID = P.Pay_Type_ID
Where Week_Start_Date = @ToStartDate
And SSN In( Select Option_Type
From Web_Control
Where Web_ID = 200 And FieldName = @UserID)
And (P.Allow_On_Sched = 0 Or S.Pay_Type_ID Is Null)

Here Sch_Daily, Pay_Types and Web_Control are tables.

What I want to know is what does the first line mean i.e
"Delete Sch_Daily". What syntax is this ? Can this query be written in a simpler form ?

Actually I need the MSAccess equivalent of this query as well.

Any suggestions ?

Regards,
IVy

Crespo24
Village Idiot

144 Posts

Posted - 2002-12-18 : 05:25:58
It is deleteing rows from the table where the condition is satisfied.

-------------------------
Go to Top of Page

harshal_in
Aged Yak Warrior

633 Posts

Posted - 2002-12-18 : 05:38:24
I don't get the query!!!!

Expect the UnExpected
Go to Top of Page

indervirsingh
Starting Member

3 Posts

Posted - 2002-12-18 : 05:52:18
Yeah well Crespo, I already knew that !!

And Harshal_In I wanted to know the exact syntax of this particular query. I did not get it either !!

Go to Top of Page

Sitka
Aged Yak Warrior

571 Posts

Posted - 2002-12-18 : 09:28:58
The Syntax is Transact-SQL.

This example shows the Transact-SQL extension used to delete records from a base table that is based on a join or correlated subquery.
The first DELETE shows the SQL-92-compatible subquery solution, and the second DELETE shows the Transact-SQL extension.
Both queries remove rows from the titleauthors table based on the titles stored in the titles table.

/* SQL-92-Standard subquery */
USE pubs
DELETE FROM titleauthor
WHERE title_id IN
(SELECT title_id
FROM titles
WHERE title LIKE '%computers%')


/* Transact-SQL extension */
USE pubs
DELETE titleauthor
FROM titleauthor INNER JOIN titles
ON titleauthor.title_id = titles.title_id
WHERE titles.title LIKE '%computers%'


Voted best SQL forum nickname...."Tutorial-D"
Go to Top of Page

indervirsingh
Starting Member

3 Posts

Posted - 2002-12-18 : 23:47:06
Thanks a lot Sitka. This pretty much clears my doubt.

Regards,
IVy

Go to Top of Page
   

- Advertisement -