Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create table based on a view

Status
Not open for further replies.

dwight1

IS-IT--Management
Aug 22, 2005
176
US
I want to create a table based on a view. Can any one advise me where i am going wrong?

create table AcctsFeb as
SELECT * FROM dbo.AcctsMonthly2
WHERE (Jan IS NOT NULL)

Thank you

Dwight
 
I think you need to do it this way

Code:
SELECT      
field1,
field2
INTO AcctsFeb
FROM  dbo.AcctsMonthly2
where (jan is not null)

Note that you cannot do select * in a select into, but if you want to change any column names you can do that as follows:
Code:
SELECT      
field1 as NewField1,
field2 as NewField2
INTO AcctsFeb
FROM  dbo.AcctsMonthly2
where (jan is not null)

Hope this helps.

Fee.

"The question should be, is it worth trying to do, not can it be done"


 
SQLDenis,

I appreciate your quick response. But my scenario is i have some 12 views for 12 months. I want the results of this view to be stored in a table so that when i make a final view i can use the tables and not views (as this views generate the results after querying the server every time they are used). I want to avoid this step of querying the server. If i have 12 tables that would increase the speed and avoid running through the main table data.

Please advise

Thank you

Dwight



 
Willif,

Thank you very much. It worked like a charm.

I appreciate your help.

Thank you ALL

Dwight
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top