I am defining one user defined table type in SQL Server 2008.
This is the code
CREATE TYPE [dbo].[PayElementTable] AS TABLE(
[EffDate] [varchar](30) NULL,
[PayEle] [varchar](50) NULL,
[ComType] [varchar](50) NULL,
[Oper] [varchar](20) NULL,
[Amount] [decimal](10, 2) NULL,
[Rowno] [varchar](10) NULL
)
GO
Then I create a procedure sptemptable
CREATE PROCEDURE sptemptable
@T PayElementTable Readonly,--user type as parameter
@CTCID int
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
END
GO
What I want to do is I want to pass datatable as @T
from C# and loop through the @T
records inside above stored procedure and with in that loop I want to call another stored proce开发者_运维技巧dure with parameter and how to pass parameter to that procedure.
How can I do this?
Calling Stored Procedure inside another one :
Execute yourSPName [coma separated parameter value list]
Loop in records of a table :
Using Cursor in SQL
Don't use the cursor . It is costly operation use while loop for iterating the records with counter variable
精彩评论