Hi folk!
I have a stored procedure with 3 input parameters.
All the parameters have their defaults.
I need to execute the stored procedure with any combination of the defined parameters.
E.g.
- EXEC pMyTestProcedure @inFirstParam = "Hello", @inSecondParam = "Folk";
- EXEC pMyTestProcedure @inFirstParam = "Hello", @inThirdParam = 7;
- EXEC pMyTestProcedure @inSecondParam = "Folk", @inThirdParam = 7;
-----
CREATE PROCEDURE pMyTestProcedure
@inFirstParam VARCHAR(100) = NULL
,@inSecondParam VARCHAR(100) = NULL
,@inThirdParam INTEGER = NULL
AS
BEGIN
SET NOCOUNT ON;
INSERT INTO tMyTestTable
(
Col1
,Col2
,Col3
)
VALUES
(
@inFirstParam
,@inSecondParam
,@inThirdParam
);
END;
-----
In my package I have a txt file as an input, and I need to process each row from the file: read a row, pass it to the stored procedure, exec the stored procedure.
I understand that I can use other approches to accomplish the goal (load the txt into the table), but I would like to make the above approach clear to me.
So, in my case I am using an "OLE DB Command" in order to execute the SP, and I have encountered a problem.
The input txt has only two columns (First_Col, Third_Col), but the procedure has three input parameters.
My purpose is to map:
- First_Col to @inFirstParam;
- Third_Col to @inThirdParam;
In spite of the fact that @inSecondParam has its default value (NULL) in the procedure code, I cannot execute the next code in the "OLE DB Command" component:
EXEC pTestParameters
@inFirstParam = ?
,@inThirdParam = ?
;
This component does not understand that I want to skip the second procedure parameter and, when being executed, it replaces @inThirdParam by @inSecondParam.
So, the SQL Server gets the call as:
EXEC pTestParameters
@inFirstParam = First_Col
,@inSecondParam = Third_Col
;
Obviously, this behaviour is completely unbecoming to me.
----
As a possible solution I consider using "Script Component".
Do you have any ideas how to get over the problem?
Thank you!
I have a stored procedure with 3 input parameters.
All the parameters have their defaults.
I need to execute the stored procedure with any combination of the defined parameters.
E.g.
- EXEC pMyTestProcedure @inFirstParam = "Hello", @inSecondParam = "Folk";
- EXEC pMyTestProcedure @inFirstParam = "Hello", @inThirdParam = 7;
- EXEC pMyTestProcedure @inSecondParam = "Folk", @inThirdParam = 7;
-----
CREATE PROCEDURE pMyTestProcedure
@inFirstParam VARCHAR(100) = NULL
,@inSecondParam VARCHAR(100) = NULL
,@inThirdParam INTEGER = NULL
AS
BEGIN
SET NOCOUNT ON;
INSERT INTO tMyTestTable
(
Col1
,Col2
,Col3
)
VALUES
(
@inFirstParam
,@inSecondParam
,@inThirdParam
);
END;
-----
In my package I have a txt file as an input, and I need to process each row from the file: read a row, pass it to the stored procedure, exec the stored procedure.
I understand that I can use other approches to accomplish the goal (load the txt into the table), but I would like to make the above approach clear to me.
So, in my case I am using an "OLE DB Command" in order to execute the SP, and I have encountered a problem.
The input txt has only two columns (First_Col, Third_Col), but the procedure has three input parameters.
My purpose is to map:
- First_Col to @inFirstParam;
- Third_Col to @inThirdParam;
In spite of the fact that @inSecondParam has its default value (NULL) in the procedure code, I cannot execute the next code in the "OLE DB Command" component:
EXEC pTestParameters
@inFirstParam = ?
,@inThirdParam = ?
;
This component does not understand that I want to skip the second procedure parameter and, when being executed, it replaces @inThirdParam by @inSecondParam.
So, the SQL Server gets the call as:
EXEC pTestParameters
@inFirstParam = First_Col
,@inSecondParam = Third_Col
;
Obviously, this behaviour is completely unbecoming to me.
----
As a possible solution I consider using "Script Component".
Do you have any ideas how to get over the problem?
Thank you!