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)
 How do I save my query results into new table

Author  Topic 

n1coltsfan
Starting Member

2 Posts

Posted - 2008-04-29 : 14:35:46
How do I save my query results into new table.... The ORIGINAL COLUMN Of course before parsing--- But the only data I want is in the three no name columns---(NO Column Name),(NO Column Name),(NO Column Name)I don’t want the original column saved back but I think it existing in the final query is blocking my Insert Into---

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-04-29 : 14:37:28
Your problem is not clear. Please provide a data example of what you mean.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

eilert
Starting Member

3 Posts

Posted - 2008-04-29 : 21:29:17
I'm not exactly sure what you're trying to accomplish, but if you are inserting into a new table, you can use the SELECT INTO syntax. You'll also have to alias any columns that are calculated in any way... For example:

SELECT
SUM(col1) AS col1,
AVG(col2) AS col2,
CASE WHEN col3 = 1 THEN 'A' ELSE 'B' END AS col3
INTO tblNew
FROM tblOld

of coarse you'd need a group by clause if you were aggregating some columns but not others, but those are just examples of when you'd need to alias columns.
Go to Top of Page
   

- Advertisement -