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.
    
        | 
                
                    | 
                            
                                | Author | Topic |  
                                    | kamii47Constraint Violating Yak Guru
 
 
                                        353 Posts | 
                                            
                                            |  Posted - 2013-09-09 : 09:43:47 
 |  
                                            | Can i Delete from multiple tables at once in sql serverI think something like this is available in mysqlDelete fe ,fd, fa,sf, sfsmFrom   dbo.FieldEnumeration As fe       Inner Join dbo.FieldDependency As fd               On fe.FieldEnumerationId = fd.FkFieldEnumerationId       Inner Join dbo.SimpleFieldDetail As sf               On fe.FkSimpleFieldDetailId = sf.SimpleFieldDetailId       Inner Join dbo.FieldAttributes As fa               On sf.SimpleFieldDetailId = fa.FkSimpleFieldDetailId       Inner Join dbo.SimpleFieldSectionMapper sfsm               On fd.ChildFieldId = sfsm.SimpleFieldSectionMappingId                  And sf.SimpleFieldDetailId = sfsm.FkSimpleFieldDetailId       Inner Join dbo.SourceSection               On dbo.SimpleFieldSectionMapper.FkSourceSectionId = dbo.SourceSection.SourceSectionId       Inner Join dbo.TemplateSource               On dbo.SourceSection.FkTemplateSourceId = dbo.TemplateSource.TemplateSourceId       Inner Join dbo.Template tm               On dbo.TemplateSource.FkTemplateId = tm.TemplateIdWhere tm.TemplateId = 1Any idea how easily i can do thisKamran ShahidPrinciple Engineer Development(MCSD.Net,MCPD.net) |  |  
                                    | James KMaster Smack Fu Yak Hacker
 
 
                                    3873 Posts | 
                                        
                                          |  Posted - 2013-09-09 : 10:26:26 
 |  
                                          | T-SQL does not allow you to delete from multiple tables in one delete statement.  If you want to preserve the atomicity of the deletions, the recommended way is to use a try-catch block and an explicit transaction.You can use joins to pick up the rows that you want to delete, but the deletion has to be targeted at a single table.T-SQL also supports cascade deletes - i.e., when you delete data from a table, you can set it up such that rows in other tables that are dependent on the row to be deleted via foreign key constraints will also get deleted. |  
                                          |  |  |  
                                    | kamii47Constraint Violating Yak Guru
 
 
                                    353 Posts | 
                                        
                                          |  Posted - 2013-09-10 : 01:07:57 
 |  
                                          | I know about the cascade delete but at the moment i needed the deletion with manual query. Could u help translating the above query into separate deletion queries.I know i might needed the temprorary table to first select the ids into them then delete one by oneKamran ShahidPrinciple Engineer Development(MCSD.Net,MCPD.net) |  
                                          |  |  |  
                                |  |  |  |