问题描述
我对mssql还是很陌生.
I'm pretty new to mssql.
我正在尝试创建一个简单的过程来获取当前过程名称的名称,以进行调试.
I'm trying to create a simple procedure to get the name of the current procedure name for debugging purpose.
这是代码.
-================================ =====================================
执行此代码时,出现此错误.
When I execute this code, I get this error.
不确定我在做什么错.请帮助
Not sure what I'm doing wrong. Please help
推荐答案
您使用的是Azure SQL数据库还是Azure SQL数据仓库?
Are you using Azure SQL Database or Azure SQL Data Warehouse?
我看到了两者的引用,但 @@ PROCID(Transact-SQL)仅适用于SQL Server和Azure SQL数据库.在任何 情况下,您需要添加一个声明语句...我相信:
I see references to both but @@PROCID (Transact-SQL) is only applicable to SQL Server and Azure SQL Database. In any case, you need to add a declare statement...I believe:
创建过程[stg].[test_procid]
AS
开始
声明@objectname varchar(200);
声明@@ procid int;
设置@ objectname = quotename(object_schema_name(@@ procid))+'.'+ quotename(object_name(@@ procid));
CREATE PROCEDURE [stg].[test_procid]
AS
BEGIN
declare @objectname varchar(200);
declare @@procid int;
set @objectname=quotename(object_schema_name(@@procid))+'.'+quotename(object_name(@@procid));
我希望这会有所帮助!
这篇关于必须将标量变量"@@ procid"声明为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!