I'm pretty new to SQL Server. I'm trying to create a simple procedure to get the name of the current procedure name for debugging purpose.
This is the code.
-- ======================================================================
-- Create Stored Procedure Template for Azure SQL Data Warehouse Database
-- ======================================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [stg].[test_procid]
AS
BEGIN
DECLARE @objectname VARCHAR(200);
SET @objectname = QUOTENAME(object_schema_name(@@procid)) + '.' + QUOTENAME(object_name(@@procid));
END
GO
When I execute this code, I get this error.
Msg 137, Level 16, State 1, Line 8
Must declare the scalar variable "@@procid".
Not sure what I'm doing wrong. Please help
Update: Thanks @Larnu and @David. I'm using Azure SQL Data Warehouse and I think that is the reason. I want this information to be passed on to another procedure in a generic way than hardcoding the procedure name.
Is there any way to do it in Azure Data Warehouse?