I Did some simple steps in my database
Step 1:
CREATE TYPE [dbo].[TempType] AS TABLE([MM] [INT])
Step 2:
CREATE PROC [DBO].[TEMP1] (@MYTAB TEMPTYPE READONLY)  
AS
BEGIN
    SELECT * 
    FROM @MYTAB
END
Step 3:
CREATE TABLE #TEMP11 ([MM] [INT])
INSERT INTO #TEMP11 
   SELECT 1 UNION 
   SELECT 2 UNION 
   SELECT 3 
SELECT * FROM #TEMP11
EXEC TEMP1 #TEMP11
Result:
(4 row(s) affected) 
(4 row(s) affected) 
Msg 206, Level 16, State 2, Procedure temp1, Line 0
Operand type clash: nvarchar is incompatible with TempType
I did it on two more servers it gave same message. What is the fault in my code. I used SQL Server 2008 R2 and SQL Server 2014 also.
Instead of creating a temporary table, create a variable of type TempType:
DECLARE  @Temp11 TempType 
INSERT INTO @Temp11 SELECT 1 UNION SELECT 2 UNION SELECT 3 
SELECT * FROM @Temp11
EXEC TEMP1  @Temp11
Your procedure is not accepting a temporary table as input parameter but parameter of type TempType. 
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With