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

Ask a Question related to Dreamweaver AppDev, Design and Development.

  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.spIssues
    @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. Similar Questions and Discussions

    1. UPDATE table2 using table1 data
      Using 4.0.20a-nt on Win2K, but the query will eventually be run on a Linux box (not sure what MySQL version). I'm trying to pull DISTINCT...
    2. How to take data out of table, restructure the table and then put the data back in
      Hi All Wonder if you could help, I have a bog standard table called STOCKPRICES that has served me well for a while, but now I need to change the...
    3. static data access
      hi, I have a static class for data access. what if i declare some private attribute like this. private static constr =...
    4. Inserting data into a table
      I am quite new to all this but am trying to create a database driven site. I have been able to use information from my sample database but I now...
    5. Inserting into one table data from 2 tables and some input data.
      Alrighty, I pull records from a database table onto a page based on vendor #. On this page I have an input box after each row of data that is just...
  3. #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

  4. #3

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

    Thanks Jules!

    Rob


    RobGT Guest

Posting Permissions

  • You may not post new threads
  • You may 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