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
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)ASSELECT * FROM @oatable As oaTBLWHERE OBJECTID = @oaobjectidORDER BY NAME;
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.