Premise: I have REFERENCES permission and every permission I should have. I am using SQL Server (AZURE) and the sqlcmd utility.
I am trying to create a stored procedure which accepts a list of device ids. For this, I have created a type.
-- Drop the table type if it already exists
IF TYPE_ID(N'schema_name.typename') IS NOT NULL
BEGIN
DROP TYPE schema_name.typename;
END
GO
CREATE TYPE schema_name.typename AS TABLE
(
DeviceID varchar(50)
);
GO
This is how the procedure looks
if OBJECT_ID('schema_name.proc_name', 'P') is not null
begin
drop procedure schema_name.proc_name;
end
go
CREATE PROCEDURE schema_name.procedure_name
(
@FromGroupID BIGINT,
@ToGroupID BIGINT,
@DeviceIDs DeviceIDTableType READONLY
)
AS
BEGIN
...code
END;
I am getting the error: Cannot find the type ‘typename’, because it does not exist or you do not have permission. I managed to create a type. The type and procedure are in the same database and same schema. I have all the required permissions. What could be wrong?