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)
 cascade deletion from tables

Author  Topic 

abbikhan
Starting Member

26 Posts

Posted - 2011-06-22 : 07:50:30
Getting Error on statement:
delete FROM [Test_DB].[dbo].[Type] , [Test_DB].dbo.[user]
where [Test_DB].[dbo].[Type].type_id=[Test_DB].dbo.[user].type_id

error:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near ','.

why is that so

Sachin.Nand

2937 Posts

Posted - 2011-06-22 : 08:36:39
Because you cannot specify multiple tables in a delete query.

PBUH

Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-06-22 : 08:52:03
delete cascade is to consider in create statement of child table.
See here for example:
http://www.sqlservercentral.com/forums/topic496734-149-1.aspx


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

abbikhan
Starting Member

26 Posts

Posted - 2011-06-22 : 09:42:15
Then how can we use 'ON DELETE CASCADE' option
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2011-06-22 : 10:10:45
Please don't do that.

Instead, first delete from the child table, then the parent.
Go to Top of Page

abbikhan
Starting Member

26 Posts

Posted - 2011-06-23 : 03:02:55
why is that so this is not the right practice..?? or some other issues.
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2011-06-23 : 10:03:44
It creates difficult to track down bugs.

It causes developers to unintentionally delete data.

It is the lazy way out of actually knowing what one is doing.

I don't allow them on my systems.
Go to Top of Page
   

- Advertisement -