Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

How to delete child records from table tradecode that not have parent on tradeco

$
0
0

I work on SQL server 2012 I need to delete rows that not have parent code type and parent code value

SQL
whatitryis;withmycteas(selectPartidfrom#TradeCodetwherePartDone=1groupbyPartidhaving(count(*)=1))deletetfrom#TradeCodetjoinmyctemonm.Partid=t.Partidselect*from#TradeCode


SQL
TradeCodeIdPartIdCodeTypeCodeValuePartDone11222ECCS-USAB123-USnull21255ECCS-USAB555-USnull31222ECCS-URBAB123-URB141255ECCS-URBAB555-URB1111255HTS-USAB900-USnull12909HTS-USAB900-USnull
Text
drop table #MappingCodeValue drop table #TradeCode create table #MappingCodeValue ( id int identity (1,1), ParentCodeType nvarchar(50), ParentCodeValue nvarchar(50), ChildCodeType nvarchar(50), ChildCodeValue nvarchar(50) ) INSERT INTO #MappingCodeValue...

Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>