I have two tables.
1- student table & 2- Score table
I want to insert value at student table & insert multi value at Score table with SP to SQL Server 2008.
for EX:
ALTER proc [dbo].[InsertIntoScore]
(
@DateReg datetime,
@stdLastName nvarchar(50),
@stdFirstName nvarchar(50),
@Description nvarchar(500),
multi value as score table...
)
AS
DECLARE @Id AS INT
BEGIN TRY
BEGIN TRANSACTION
INSERT INTO Student(DateReg,stdLastName,stdFirstName,[Description])
VALUES (@DateReg,@stdLastName,@stdFirstName,@Description)
set @Id = SCOPE_IDENTITY()
insert multi value at Score table...
COMMIT
END TRY
BEGIN CATCH
IF @@TRANCOUNT > 0
ROLLBACK
END CATCH
please help me…
You should use Table-Valued Parameters
Create a Sql Type for the table you will pass in
pass your datatable from C# code into the stored procedure using the above defined type
in c# pass the datatable in this way