Results 1 to 2 of 2

Thread: Add new record Stored Procedure

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Indiana
    Posts
    612

    Add new record Stored Procedure

    Could someone please provide an example of a Stored Procedure that inserts records into an existing SQL table please?

    Thanks
    David Wilhelm

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    Basically, you may need to create a parameter for every field in your database table.
    Code:
    Create Procedure dbo.insInsertExample
          @Field1 As varchar(20),
          @Field2 As datetime,
          @Field4 As int = 0,
          @NewId As int Output
    
    As
    
    Insert Into SomeTable Values (@Field1, @Field2, Default, @Field4)
    
    Set @NewId = @@Identity 'or Scope_Identity if using SQL 2K

Posting Permissions

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



Click Here to Expand Forum to Full Width