Professional Web Applications Themes

SQL: Inserting data from table1 with static data into table 2 - Dreamweaver AppDev

Hi, I'm trying to create an SP in SQL Server 2000 that will read in a load of row values and insert them, along with two static values, into another table. I can't get my head to work right at the moment either, which isn't helping :) Here's what I have, which obviously doesn't work - any suggestions appreciated. CREATE PROCEDURE dbo.sues UserID int AS BEGIN INSERT INTO t1 (ID, OtherID, MainValue) VALUES (1272, 5, (SELECT MainValue FROM t2 WHERE t2.ID = 1272) ) END GO There must be an easy way to do this, I just can't think straight ...

  1. #1

    Default SQL: Inserting data from table1 with static data into table 2

    Hi,
    I'm trying to create an SP in SQL Server 2000 that will read in a load of
    row values and insert them, along with two static values, into another
    table.
    I can't get my head to work right at the moment either, which isn't helping
    :)

    Here's what I have, which obviously doesn't work - any suggestions
    appreciated.

    CREATE PROCEDURE dbo.sues
    UserID int
    AS
    BEGIN
    INSERT INTO t1 (ID, OtherID, MainValue)
    VALUES (1272, 5, (SELECT MainValue
    FROM t2
    WHERE t2.ID = 1272)
    )
    END
    GO

    There must be an easy way to do this, I just can't think straight at the
    moment!
    Any help appreciated...
    Cheers,
    Rob


    RobGT Guest

  2. #2

    Default Re: Inserting data from table1 with static data into table 2

    You need to clear you mind of clutter :)

    INSERT INTO t1 (ID, OtherID, MainValue)
    SELECT 1272,5, MainValue
    FROM t2
    WHERE t2.ID = 1272

    --
    Jules
    [url]http://www.charon.co.uk/charoncart[/url]
    Charon Cart 3
    Shopping Cart Extension for Dreamweaver MX/MX 2004



    Julian Roberts Guest

  3. #3

    Default Re: Inserting data from table1 with static data into table 2

    Thanks Jules!

    Rob


    RobGT Guest

Similar Threads

  1. Replies: 0
    Last Post: June 1st, 03:15 AM
  2. UPDATE table2 using table1 data
    By Trudge in forum MySQL
    Replies: 1
    Last Post: April 14th, 08:46 AM
  3. Replies: 4
    Last Post: October 27th, 03:01 PM
  4. Inserting data into a table
    By Geoff Wickens in forum ASP
    Replies: 1
    Last Post: August 25th, 10:06 AM
  5. Replies: 1
    Last Post: July 10th, 08:29 PM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139