Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2009
    Posts
    1

    Unanswered: Stored procedure to insert into different tables

    I am working on asp.net application. I have to insert an array of elements into database. These elements should insert into different tables. Can any one show how to write a stored procedure?

    Thansk in advance

  2. #2
    Join Date
    Dec 2008
    Posts
    135
    CREATE PROC [dbo].[samplesp]
    (
    @ID INT,
    @col1 INT,
    @col2 INT,
    @col3 INT,..........
    )
    AS
    SET NOCOUNT ON
    BEGIN
    INSERT INTO tbl1
    (id,col1,col2,...)
    SELECT @id,@col1

    INSERT INTO tbl2
    (id,col2)
    SELECT @id,@col2

    INSERT INTO tbl3
    (id,col3)
    SELECT @id,@col3
    END
    SET NOCOUNT OFF

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •