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 2008 Forums
 Transact-SQL (2008)
 Two from clause in DELETE statement -- issue

Author  Topic 

naveenjv
Starting Member

9 Posts

Posted - 2015-04-17 : 06:08:01
Hi Experts,

I am supposed to delete all rows from USER and its child tables based on PracticeID = '55' filter condition.

I have dynamically generated queries to delete child table first followed by parent. Table [EncounterSignOff] si child and [User] is parent.

I would like to know, whether the Query 1 is valid for deleting child records?

Query:1

DELETE Top(100000) FROM [dbo].[EncounterSignOff]
FROM [dbo].[User] INNER JOIN [dbo].[EncounterSignOff] ON [User].[UserID] = [EncounterSignOff].[UserId]
WHERE [User].PracticeID = '55';
Query:2

DELETE Top(100000) FROM [dbo].[User] WHERE [User].PracticeID = '55';

Thanks,

Naveen

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2015-04-17 : 08:41:20
Seems valid to me. It is not ANSI standard SQL, but is valid T-SQL extension. So, as long as you are using Microsoft SQL Server, your query is valid.
Go to Top of Page

naveenjv
Starting Member

9 Posts

Posted - 2015-04-17 : 09:27:44
Thanks James

quote:
Originally posted by James K

Seems valid to me. It is not ANSI standard SQL, but is valid T-SQL extension. So, as long as you are using Microsoft SQL Server, your query is valid.

Go to Top of Page
   

- Advertisement -