locked
How to get all Child table records based on Parent ID RRS feed

  • Question

  • User-1353133982 posted

    Hi All,

    I have 4 different Tables 

    select * from TMSystem 
    
    -- for each system there will be n no.of Sets
    
    select * from TMContentSet 
    
    --for each set there will be n no.of Items
    
    select * from TMContentItem 
    
    --for each Item there will be n no.of Versions
    
    select * from TMContentItemVersions 

    Now when i provide System Id, I have to retrieve all the related child records from remaining 3 tables

    Now after retrieving child data, i have to insert those records respectively again withh different system Id's

    for example

    Below are the tables data for system Id = 6

    sets

    ContentSetId	SystemCategoryId	ContentSetName	            Context	            TranslationInstructions	
    1	           1	                 Menu Content	            Menu context	      Translate directly.		
    7	           1	                 Mobile Native Content Set  Mobile content context    Mobile content translatin	

    Now i have to insert same records with different system Id like below

    ContentSetId	SystemCategoryId	ContentSetName	            Context	            TranslationInstructions	
    66	           2	                 Menu Content	            Menu context	      Translate directly.		
    67	           2	                 Mobile Native Content Set  Mobile content context    Mobile content translatin	

    Now for each set there are Items like below

    ContentSetId	ContentItemId	ContentName	             Context
    1	             1	         Nearest Store	            This piece of content is for Nearest Store.
    7	            21	         Mobile Native             Mobile Native Item1234
    7		    22           Mobile Native Item12344	Mobile Native Item12345
    7		    23            Mobile Native Item1234kjojij	Mobile Native Item1234lkmkjl

    Now i have to inset Items data for inserted Set Data like 

    ContentSetId	ContentItemId	ContentName	             Context
    66	             25	         Nearest Store	            This piece of content is for Nearest Store.
    67	            26	         Mobile Native             Mobile Native Item1234
    67		    27           Mobile Native Item12344	Mobile Native Item12345
    67		    28            Mobile Native Item1234kjojij	Mobile Native Item1234lkmkjl


    Now for each Set there will be versions data like below

    ItemVersionId	ContentItemId	VersionNameId	MnLength	MxLength	ContentText
    1	            1	            14	           0	          100	        Your nearest store is
    48	           21	            14	           0	          100	        Mobile Native Item123 full
    51	          22	            15	           0	          100	        Mobile Native Item123 short
    52	          22	            14	           0	          100	        Mobile Native Item123 full
    54	          23	            14	           0	          100	        Mobile Native Item123 fulljmj
    55	          23	            16	           0	          100	        Mobile Native Item123 DM
    57	          21	            14	           0	          100	        Mobile Native Item1234

    Now i have to insert data like below

    ItemVersionId	ContentItemId	VersionNameId	MnLength	MxLength	ContentText
    58	          25	            14	           0	          100	        Your nearest store is
    59	          26	            14	           0	          100	        Mobile Native Item123 full
    60	          27	            15	           0	          100	        Mobile Native Item123 short
    61	          27	            14	           0	          100	        Mobile Native Item123 full
    62	          28	            14	           0	          100	        Mobile Native Item123 fulljmj
    63	          28	            16	           0	          100	        Mobile Native Item123 DM
    64	          26	            14	           0	          100	        Mobile Native Item1234


    In this way i have to insert data accordingly with giving only systemId as input in a storedprocedure.

    Please help me to achieve this.

    Friday, January 1, 2016 4:24 AM

All replies

  • User-62323503 posted

    Is there any relation between old and new Id's or New Id's are auto generated i.e. Identity?

    Friday, January 1, 2016 11:58 AM