SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Multiple inserts with MS SQL using a stored proceedure

    hello,
    I have a phone book on my wesbite and would like to have users insert multiple phone numbers into the phone book. I am using the stored proceedure below. But it gives an error

    whats wrong with this and how do i concatenate multiple inserts the most efficient way ?

    thanks
    Afrika


    Code:
    AS INSERT INTO [1newday_com_sql].[dbo].[sms_phonebook] 
    	 ( [username],
    	 [Phone_number],
    	 [Nickname]) 
     
    VALUES 
    	( @username_1,
    	 @Phone_number_1,
    	 @Nickname_1)
    union all  
    ( @username_2,
    	 @Phone_number_2,
    	 @Nickname_2)

  2. #2
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hello,
    I just seen my mistake
    I was using values instead of select

    just corrected it

    INSERT INTO [1newday_com_sql].[dbo].[sms_phonebook] (
    [username],
    [Phone_number],
    [Nickname])
    SELECT
    @username_1,
    @Phone_number_1,
    @Nickname_1
    union all
    SELECT @username_2,
    @Phone_number_2,
    @Nickname_2


Bookmarks

Posting Permissions

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