2

The following script creates a stored procedure (mysproc.sql):

/* A table type with 1 column (NVARCHAR(200)) of names */
CREATE TYPE [SchemaName].[NameList] AS TABLE(
    [Name] [NVARCHAR](200)
)
GO

ALTER PROCEDURE [SchemaName].[AlterNameAccess] 
@pNames AS [SchemaName].[NameList] READONLY
    AS
    BEGIN

        -- Logic Here ...

    END
GO

When the script above is ran, another script is ran that calls the stored procedure is called like so (runsproc.sql):

DECLARE @Names AS [SchemaName].[NameList]

INSERT INTO @Names -- Logic ...

EXEC [SchemaName].[AlterNameAccess] 
@pNames = @Names

RoundhousE is used to run these scripts in order... locally RoundhousE will run these scripts correctly, however when running RoundhousE on Azure an error occurs when DECLARE @Names AS [SchemaName].[NameList] is declared... saying the user defined type is not being defined despite it actually being defined.

Here is the error message RoundHousE provides:

2019-09-17 18:52:04,358 [INFO ] -  Running runsproc.sql on (local)
2019-09-17 18:52:06,686 [ERROR] - 
*** Error executing file 'runsproc.sql'. ***

2019-09-17 18:52:06,701 [ERROR] - Database deployment encountered an error. You were running in a transaction though, so the database should be in the state it was in prior to this piece running. This does not include a drop/create or any creation of a database, as those items can not run in a transaction.
System.Data.SqlClient.SqlException: Column, parameter, or variable #4: Cannot find data type SchemaName.NameList.
Must declare the table variable "@Names".
Must declare the table variable "@Names".
Parameter or variable '@Names' has an invalid data type.
MinistryOfChaps
  • 1,458
  • 18
  • 31
  • Hi. According to my error message, you may not successfully create the stored procedure when you run the script ```runsproc.sql```. Please try to run the script after the stored procedure is successfully created. – Jim Xu Sep 19 '19 at 07:10
  • @JimXu according to RoundhousE logs, the sproc script runs successfully on deployment. – MinistryOfChaps Sep 19 '19 at 10:04
  • According to your error message, when you run the ```sproc ```, your sql database does not have data type SchemaName.NameList. So I think you need to run sproc script after you run the script mysproc successfully. – Jim Xu Sep 20 '19 at 05:44

0 Answers0