Avatar of LovetoLaugh
LovetoLaugh
Flag for United States of America asked on

SQL Server 2000 Error Must declare the variable '@oatable'.

When I execute the following Code in sql query analyzer I get the error:

Server: Msg 137, Level 15, State 2, Procedure oasp_oaGetNAME, Line 8
Must declare the variable '@oatable'.

Any suggestions?
SQL

Avatar of undefined
Last Comment
BrandonGalderisi

8/22/2022 - Mon
BrandonGalderisi

Do you have @oaTable declared in your procedure?
richardSlade

Hi,
Need to see your code really, but it could be as Brandon suggested above, or look for a missing comma, a mis-spelling of the variable. From the line number, I guess your code is quite short.

LovetoLaugh

ASKER
Sorry about that, I thought I had copied the code snippet.
CREATE PROCEDURE dbo.oasp_oaGetNAME 
@oaobjectid uniqueidentifier, @oatable nvarchar (32)
 
AS
 
SELECT * 
FROM @oatable As oaTBL
WHERE OBJECTID = @oaobjectid
ORDER BY NAME;

Open in new window

Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
ASKER CERTIFIED SOLUTION
BrandonGalderisi

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
LovetoLaugh

ASKER
Thank you.  That works great.  
Do you know if it would be better to execute this stored procedure from an ASP page, or just execute the dynamic SQL from the ASP page?
BrandonGalderisi

I am ALWAYS in favor of stored procedures.  It makes your database management reside where it belongs, in the database.  Although a procedure as generic as this isn't a good example of that.