Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Script won't create a stored procedure
Message
 
 
To
12/04/2002 10:09:01
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Miscellaneous
Thread ID:
00644255
Message ID:
00644263
Views:
11
You cannot select from a cursor in Sql Server. Try to combine everithing in one query or use temporary table instead of cursor.

>Hell Group,
>
>The script has a cursor in it named maxgpa. I get the error message "Could not find table maxgpa. Will try to resolve this table later. The script doesn't put the stored procedure into the database.
>The script is:
>/****** Object: Stored Procedure dbo.sp_gpahist Script Date: 4/12/2002 9:46:42 AM ******/
>if exist stuff deleted..
>CREATE PROCEDURE sp_gpahist
> AS
>if exists (select * from sysobjects where id = object_id(N'[dbo].[cisgpahist]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
>drop table [dbo].[cisgpahist]
>
>DECLARE MaxGPA CURSOR
> FOR
>SELECT MAX(dbo.gpahist.gpauniq) AS gpauniq,
> dbo.gpahist.suniq
>FROM dbo.jw1_distinct_suniq_for_Career_Center INNER JOIN
> dbo.gpahist ON
> dbo.jw1_distinct_suniq_for_Career_Center.suniq = dbo.gpahist.suniq
>GROUP BY dbo.gpahist.suniq
>
>OPEN MaxGPA
>
>
>SELECT dbo.gpahist.suniq, gpahist.cumgpa
>INTO cisgpahist
>FROM maxgpa INNER JOIN
> dbo.gpahist ON maxgpa.gpauniq = dbo.gpahist.gpauniq
>
>CLOSE MAXGPA
>DEALLOCATE MAXGPA
>
>GO
>
>SET QUOTED_IDENTIFIER OFF SET ANSI_NULLS ON
>GO
>how do i fix this??
>
>Thank you very much
>Jim
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform