SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Stored procedure/Views/Table
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

obezyanka
Starting Member

24 Posts

Posted - 09/24/2007 :  13:39:21  Show Profile
How can I create a stored procedure that combines the results from three views, and puts them in a temp table?

Zoroaster
Aged Yak Warrior

USA
702 Posts

Posted - 09/24/2007 :  13:50:33  Show Profile
Need the DDL for the views.

Basically once you have the results you want in a query you will need to SELECT INTO to load then into a temp table.




Future guru in the making.
Go to Top of Page

obezyanka
Starting Member

24 Posts

Posted - 09/24/2007 :  13:56:42  Show Profile
this is my stored procedure:
--------------------
CREATE PROCEDURE [dbo].[test] AS
insert INTO TempTable (...)
SELECT ...
FROM view
GO
--------------------
I don't get error messages but it doesn't creat the table I need and doesn't insert anything. What's wrong with this procedure?
Go to Top of Page

rmiao
Flowing Fount of Yak Knowledge

USA
7266 Posts

Posted - 09/24/2007 :  23:02:11  Show Profile
If the table doesn't exist, should use 'select ... to TempTable from view ...'.
Go to Top of Page

jackv
Flowing Fount of Yak Knowledge

United Kingdom
2004 Posts

Posted - 09/25/2007 :  10:01:44  Show Profile  Visit jackv's Homepage
--create the #temp table

SELECT Column1, Column2, Column3,
INTO #temp1
FROM myView


Jack Vamvas
--------------------
Search IT jobs from multiple sources- http://www.ITjobfeed.com/SQL
Go to Top of Page

obezyanka
Starting Member

24 Posts

Posted - 09/25/2007 :  10:25:25  Show Profile
I got the error:
Incorrect syntax near the keyword 'INTO'.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30113 Posts

Posted - 09/25/2007 :  10:38:10  Show Profile  Visit SwePeso's Homepage
Cross posting
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=89949



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000