Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8215089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:40:20+00:00 2026-06-07T11:40:20+00:00

I have two tables. 1- student table & 2- Score table I want to

  • 0

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…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T11:40:21+00:00Added an answer on June 7, 2026 at 11:40 am

    You should use Table-Valued Parameters

    Create a Sql Type for the table you will pass in

    CREATE TYPE dbo.ScoreType AS TABLE ( ScoreID int, StudentID int, etc.... ) 
    

    pass your datatable from C# code into the stored procedure using the above defined type

    ALTER proc [dbo].[InsertIntoScore] 
    ( @DateReg datetime, @stdLastName nvarchar(50), @stdFirstName nvarchar(50), 
    @Description nvarchar(500),  @tvpScore ScoreType) 
    AS 
       .....
       INSERT INTO dbo.Score (ScoreID, StudentID, ....)     
       SELECT dt.ScoreID, @id, .... FROM @tvpScore AS dt; 
    

    in c# pass the datatable in this way

    SqlCommand insertCommand = new SqlCommand("InsertIntoScore", sqlConnection); 
    SqlParameter p1 = insertCommand.Parameters.AddWithValue("@tvpScore", dtScore); 
    p1.SqlDbType = SqlDbType.Structured; 
    p1.TypeName = "dbo.ScoreType"; 
    .....
    insertCommand.ExecuteNonQuery(); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables associated by FK. Table student is mapped like this: @Entity
I have a table student(id, name, department, age, score). I want to find the
I have two tables, say teacher and student. I want to build a third
I have following two tables (student and marks): In student table I have information
I have tables like these two test_table date student test 2012-05-31 Alice Math 2012-05-31
I have a two tables Student -------- Id Name 1 John 2 David 3
I have two tables: subject and student. I'm trying to count the number of
Assume I have two tables, Student Test Id Name TestId Type StudentId -- ----
I have two tables: table a ida valuea 1 a 2 b 3 c
I have two tables. In the one table I have a list of dorm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.