You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure SQL Server中使用表类型创建存储过程时提示无法找到类型的问题求助

Azure SQL Server中使用表类型创建存储过程时提示无法找到类型的问题求助

大家好,我目前在Azure SQL Server上用sqlcmd工具操作,已经拥有REFERENCES权限和所有必要的权限,现在遇到了一个创建带表类型参数的存储过程的问题,想请教一下各位。

我需要创建一个接收设备ID列表的存储过程,所以先定义了对应的表类型,代码如下:

-- Drop the table type if it already exists
IF TYPE_ID(N'schemaname.typename') IS NOT NULL
BEGIN
    DROP TYPE schemaname.typename;
END
GO

CREATE TYPE schemaname.typename AS TABLE
(
    DeviceID varchar(50)
);
GO

之后我编写了存储过程的代码:

if OBJECT_ID('schemaname.procname',  'P') is not null
begin
    drop procedure schemaname.procname;
end
go

CREATE PROCEDURE schemaname.procname
(
    @FromGroupID BIGINT,
    @ToGroupID BIGINT,
    @DeviceIDs schemaname.typename READONLY
)
AS
BEGIN
   ...code
END;

现在的问题是,执行存储过程创建语句时,我收到了错误提示:Cannot find the type 'typename', because it does not exist or you do not have permission.

我确认自己已经成功创建了这个表类型,而且类型和存储过程都在同一个数据库、同一个schema下,权限也都具备,但还是遇到了这个错误,有没有大佬能帮忙分析下原因呀?

备注:内容来源于stack exchange,提问作者explosivemango

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.16 10:43:12