Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
(Parent Grid) Doc_No                            (ChildGrid) Material  Quantity
              112233                                        Pipes       8
                                                            cubes       10
                                                            Piping      20

              123125                                        Pipes       5
                                                            Rcc         2


Doc_No is taken from DB, Material,Quantity is from temparory DataTable(material,Quantity).
Now,my question is to inser Parent Grid Doc_No into my temparory DataTable

like this.
Temprory DataTable

Doc_No     Material        Quantity
112233     Pipes           8
112233     cubes           10
......


How to do this can anyone help me to solve this issue....

Thanks in advance....
Posted
Updated 30-Sep-12 18:55pm
v2
Comments
Sandeep Mewara 29-Sep-12 9:35am    
Is the column Doc_no defined in temp table?
[no name] 1-Oct-12 0:02am    
yes, Doc_No is also defined in Child Grid also and make it visible false.

1 solution

Probably you don't need to use temporary table, you can use simple SELECT query. If the data are stored in two different tables, like Document and Document_Details and they are related by Doc_No, you can use something like this:
SQL
SELECT D.Doc_No, DD.Material, DD.Quantity
FROM Document AS D
    LEFT JOIN Document_Details AS DD ON D.Doc_No = DD.Doc_No


But if you need it:
SQL
CREATE TABLE #tt (Doc_No INT, Material NVARCHAR(300), Quantity INT)

INSERT INTO #tt (Doc_No, Material, Quantity)
SELECT D.Doc_No, DD.Material, DD.Quantity
FROM Document AS D
    LEFT JOIN Document_Details AS DD ON D.Doc_No = DD.Doc_No

SELECT *
FROM #tt

DROP TABLE #tt
 
Share this answer
 
v2
Comments
Sandeep Mewara 29-Sep-12 9:54am    
Will this do what OP asks?
"Now,my question is to inser Parent Grid Doc_No into my temparory DataTable"

I guess, your query simply selects and is not inserting anything in temptable.
Maciej Los 29-Sep-12 10:05am    
You are right, my query is a simply select instruction, because i'm not sure that OP realy need temporary table. ;)
Do you suggest me to correct my answer (rhetorical question, because i've change it now)?
Thanks Sandeep ;)
Sandeep Mewara 29-Sep-12 10:47am    
It's ok. I see you already updated it.

My 5 for the answer.
Maciej Los 29-Sep-12 10:49am    
Thank you, Sandeep ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900