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)
 Stored procedure/Views/Table

Author  Topic 

obezyanka
Starting Member

24 Posts

Posted - 2007-09-24 : 13:39:21
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

702 Posts

Posted - 2007-09-24 : 13:50:33
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 - 2007-09-24 : 13:56:42
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
Master Smack Fu Yak Hacker

7266 Posts

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

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2007-09-25 : 10:01:44
--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 - 2007-09-25 : 10:25:25
I got the error:
Incorrect syntax near the keyword 'INTO'.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-09-25 : 10:38:10
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
   

- Advertisement -