Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
SELECT     course.Courseno,ids.PaperID
FROM         course CROSS JOIN
                      ids WHERE course.Courseno=ids.Courseno;


i want to perform a query on the table resulting from this query. Is it possible to to store the result in another table?
Posted

SQL
 Insert into TableName SELECT     course.Courseno,ids.PaperID
FROM         course CROSS JOIN
                      ids WHERE course.Courseno=ids.Courseno;
 
Share this answer
 
Comments
codingisok101 24-Aug-12 6:52am    
when i use this syntax it says invalid object name for the table name.
What do i do?
Kamalkant(kk) 24-Aug-12 8:23am    
In palce of TableName write your table name
Try this
SQL
with courseIdTemp (Courceno , PaperID) as
(
SELECT     course.Courseno,ids.PaperID
FROM         course CROSS JOIN
                      ids WHERE course.Courseno=ids.Courseno

)

Select * from courseIDTemp 


or
SQL
SELECT     course.Courseno,ids.PaperID
into CourceIDMix
FROM   course CROSS JOIN
                      ids WHERE course.Courseno=ids.Courseno
select * from CourceIDMix
 
Share this answer
 
Comments
codingisok101 24-Aug-12 5:15am    
SELECT course.Courseno, ids.PaperID
INTO courid
FROM course INNER JOIN
ids ON course.Courseno = ids.Courseno;

SELECT * FROM courid;


There is already an object named 'courid' in the database.

this is what i get as the error
pradiprenushe 24-Aug-12 5:18am    
tru this wahat about first one
SELECT course.Courseno, ids.PaperID INTO courid FROM course INNER JOIN ids ON course.Courseno = ids.Courseno;
SELECT * FROM courid;
drop table courid
codingisok101 24-Aug-12 5:29am    
how will this store the result in a table? if i drop it?
pradiprenushe 24-Aug-12 5:34am    
You want it for temporary purpose or want to save it permanently?
Before droping table you can do your querying to that table.
friend,

create temporary table and move the content

Quick Overview: Temporary Tables in SQL Server 2005[^]

Regards,
~~Karthik.J~~
 
Share this answer
 
Incase of C# coding

C#
DataTable NameAdressPhones = new DataTable(); 

DataTable NameAdress = new DataTable(); 

For that I do

            foreach (DataRow sourcerow in NameAdressPhones.Rows)
            {
                DataRow destRow = NameAdress.NewRow();
                foreach (string colname in columns)
                {
                    destRow[colname] = sourcerow[colname];
                }
                NameAdress.Rows.Add(destRow);
            }

~~Karthik.J~~
 
Share this answer
 
v2
Yes you can store this on a temp table.
 
Share this answer
 

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