Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I attached a DB in to SQL Server 2022 version and added a new table URLabelHeader. While adding a new stored procedure I am getting the following error.

SQL
CREATE PROCEDURE [dbo].[spSaveURLprocess]  
(  
      @tblURLlabelHeader [dbo].tblURLabelHeader Readonly
)
AS  
BEGIN  
SET NOCOUNT ON;.....


Error Message:

Msg 2715, Level 16, State 3, Procedure spSaveURLprocess, Line 10 [Batch Start Line 6]
Column, parameter, or variable #1: Cannot find data type dbo.tblURLlabelHeader.
Parameter or variable '@tblURLlabelHeader' has an invalid data type.


The Parameter @tblURLlabelHeader cannot be declared READONLY since it is not a table-valued parameter.

Can anyone please help me!

What I have tried:

It works except the newly created table. Old table based Stored Procedures can be created. Thanks in Advance.
Posted
Updated 11-Feb-24 17:13pm
v2

1 solution

As per the the error message and create procedure statement, it appears that the table type does not exist. You might need to generate a user-defined table type for tblURLabelHeader.
SQL
/* Create a table type. */
CREATE TYPE tblURLabelHeader 
   AS TABLE
      ( ColumnName1 datatype,
		ColumnName2 datatype );
GO
You can verify the table types through the following query for 'tblURLabelHeader' and other newly created tables.
SQL
SELECT *
FROM sys.table_types
WHERE name = 'yourtabletypename' -- In your case is 'tblURLabelHeader'
You can also refer to the below example/link for more details about how to create a user-defined table type. CREATE TYPE (Transact-SQL) - SQL Server | Microsoft Learn[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900