Invalid data type when using a specific table type

I am new to table-value in SQL Server 2008. I tried to create a custom table with the query

USE [DB_user]
GO
CREATE TYPE [dbo].[ApproveAddsIds] AS TABLE(
    [Ids] [bigint] NULL
)
GO 

When I tried to use a table type in a stored procedure

USE [DB_user]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create  PROCEDURE [dbo].[GetTopTopic]
    @dt  [dbo].[ApproveAddsIds] READONLY      
AS
BEGIN

END

I got two errors:

@dt has an invalid data type.
The @dt parameter cannot be read-only because it is not a table parameter.

So, I tried to find out the reason for this, since the first request was successfully completed. I thought he was due to permissions and therefore tried

GRANT EXEC ON TYPE::[schema].[typename] TO [User]
GO

But the error continues, I do not know what the problem is.

- , , @dt [dbo].[ApproveAddsIds] READONLY , AS . , . , .

+4
4

. , , SQL Server, SQL Server Management Studio.

. SQL Server 2012, , 2008 .

+11

(UDTT) , . SQL Server Management Studio. , , / .

, IntelliSense SSMS UDTT squiggly. ...

, . , USE, . , Ctrl + Shift + R "" > "IntelliSense" > " " . , , ...

... -...

https://www.mssqltips.com/sqlservertip/2591/troubleshooting-intellisense-in-sql-server-management-studio-2012/

MSDN :

https://msdn.microsoft.com/en-us/library/ms173434.aspx

IntelliSense , , .

, IntelliSense - , , SMSS - script, .

+1

. BEGIN END . ,

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create  PROCEDURE [dbo].[GetTopTopic](
   @dt  [dbo].[ApproveAddsIds] READONLY  
      )   
AS
BEGIN
--Write some statements here
print 'hi'
END
0

I ran into the same problem. It really was connected with IntelliSense. Below are the steps that I followed to fix this. I am using SQL Management Studio 2017.

1) In the code editor window for the stored procedure, right-click.

2) In the short outputs menu, select "IntelliSense Enabled"

After that, the code editor did not detect errors. Hope this helps.

0
source

All Articles