Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Saving Query in a New Table

Author  Topic 

rcr69er
Constraint Violating Yak Guru

327 Posts

Posted - 2007-12-06 : 09:43:38
Hi

I've just created a query which returns over 20 field. Is it possible to store the results in a new table using sql?

Thanks

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-12-06 : 09:49:19
[code]Select col1, col2, col3,....
to NewTable
From OldTable[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2007-12-06 : 09:50:09
Select col1, col2..etc
into tablename
from [...]

Or

Insert into table (<fieldnames>)
select [...]
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-12-06 : 10:08:25
It is better you pre-create a table and then insert into that so that new table would have all the indices that source table has

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

jordanam
Yak Posting Veteran

62 Posts

Posted - 2007-12-06 : 11:24:54
If you are looking to manipulate the result-set, remember that you can also just copy/paste the output into a program like Excel, or save the results directly as a CSV.
Go to Top of Page
   

- Advertisement -