Delete from Table From Table inner join TableOther On Table.Id=TableOther.Id
注意上面是两个From
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
Declare @rowCount int Declare @SQL nvarchar(1000) set @rowCount=0 Set @SQL='' select @RowCount=count(1) from KB_Lable_IsScanSync where IsSync=1 Set @rowcount=cast( (@RowCount * 2) /3 as int) Set @SQL=' Delete From KB_Lable_IsScanSync From KB_Lable_IsScanSync s inner join ( select top '+ cast(@rowCount as nvarchar(50))+' RecId from KB_Lable_IsScanSync where IsSync=1 order by RecId ) as t on t.RecId=s.RecId ' Exec(@SQL)