执行Table类型参数时出错

时间:2017-06-14 06:43:56

标签: sql-server biztalk biztalk-2013

我正在尝试使用带有以下代码的BizTalk将数据插入到表中。但我面临错误,因为“程序或函数Emp_Details指定了太多参数。”

有人可以帮我解决问题吗?

ALTER PROCEDURE [dbo].[Emp_Details]

                (@InsertDetails InsertDetailsType readonly)
    AS
    Begin 

    Truncate table [dbo].[Emp_Details]

          INSERT INTO [dbo].[Emp_Details]
               (
                [NAME],
                [DESCRIPTION],
                [EMPID]

            )
        select 

                [NAME],
                [DESCRIPTION],
                [EMPID]
    from @InsertDetails;


    Begin
    if exists(select 1 from [dbo].[Emp_Details]where NAME='Raul')

    Delete from [Emp_Details]where NAME='Raul'

    End 

    end

1 个答案:

答案 0 :(得分:-1)

重新发布以前用于参考的相同示例代码。

USE <Database>
GO

/* This is a template table */
CREATE TYPE Emp_Details AS TABLE   
( [Name]        VARCHAR(100)  
, [Description] VARCHAR(100) 
, [Address]     VARCHAR(100));  
GO

/* The following is your Table Emp_Details which you must be having already*/
CREATE TABLE Emp_Details
( [Name]        VARCHAR(100)  
, [Description] VARCHAR(100) 
, [Address]     VARCHAR(100));  
GO 

/* Consider this as your Input Data i.e CSV file or Excel (Note: I have created a table for sample)*/
CREATE TABLE Emp_Details1
( [Name]        VARCHAR(100)  
, [Description] VARCHAR(100) 
, [Address]     VARCHAR(100));  
GO 


INSERT INTO Emp_Details1 VALUES ('John','Test','123')
INSERT INTO Emp_Details1 VALUES ('John1','Test1','1234')
INSERT INTO Emp_Details1 VALUES ('John2','Test2','1235')
GO

SELECT * FROM Emp_Details

/* Declare a variable that references the type. So when you reference a `TYPE` it takes the table template which we created previously*/  
DECLARE @Emp AS Emp_Details;  

/* Add data to the table variable. In your case push the data that you get into the @Emp */  
INSERT INTO @Emp ([Name], [Description], [Address])  
    SELECT [Name], [Description], [Address]
    FROM Emp_Details1;  

/* Pass the table variable data to a stored procedure. */  
EXEC [dbo].[Insert_Deatils]  @Emp;  
GO 

SELECT * FROM Emp_Details