Professional Web Applications Themes

change cursor code to set based code - Microsoft SQL / MS SQL Server

INSERT INTO TableA (Col1, Col2...) SELECT Col1,Col2... FROM TableB -- Andrew J. Kelly SQL Server MVP "Andrea Worley" <k_ragehotmail.com> wrote in message news:089901c34559$5c6cb5a0$a001280aphx.gbl... > Is there a way to insert a SELECT statement result into an > existing table in a stored proc? Currently, I do a select > statement to get the data I want, then I use a cursor to > walk through the records, inserting each one into a log > table. I can't use a view and DTS to append these records > because I hard code some values and there is an autonumber > in ...

  1. #1

    Default Re: change cursor code to set based code

    INSERT INTO TableA (Col1, Col2...)
    SELECT Col1,Col2... FROM TableB


    --

    Andrew J. Kelly
    SQL Server MVP


    "Andrea Worley" <k_ragehotmail.com> wrote in message
    news:089901c34559$5c6cb5a0$a001280aphx.gbl...
    > Is there a way to insert a SELECT statement result into an
    > existing table in a stored proc? Currently, I do a select
    > statement to get the data I want, then I use a cursor to
    > walk through the records, inserting each one into a log
    > table. I can't use a view and DTS to append these records
    > because I hard code some values and there is an autonumber
    > in the table I am inserting to.
    >
    > So, is there a way to use a view and DTS even with these
    > factors? Or is there a way to append the SELECT results
    > in a stored proc without using cursors? I'm just trying
    > to find a more efficient method. Thank you.

    Andrew J. Kelly Guest

  2. #2

    Default Re: change cursor code to set based code

    Thanks so much. It's the simple things that get you
    sometimes. That worked perfectly.

    >-----Original Message-----
    >INSERT INTO TableA (Col1, Col2...)
    > SELECT Col1,Col2... FROM TableB
    >
    >
    >--
    >
    >Andrew J. Kelly
    >SQL Server MVP
    >
    >
    >"Andrea Worley" <k_ragehotmail.com> wrote in message
    >news:089901c34559$5c6cb5a0$a001280aphx.gbl...
    >> Is there a way to insert a SELECT statement result into
    an
    >> existing table in a stored proc? Currently, I do a
    select
    >> statement to get the data I want, then I use a cursor to
    >> walk through the records, inserting each one into a log
    >> table. I can't use a view and DTS to append these
    records
    >> because I hard code some values and there is an
    autonumber
    >> in the table I am inserting to.
    >>
    >> So, is there a way to use a view and DTS even with these
    >> factors? Or is there a way to append the SELECT results
    >> in a stored proc without using cursors? I'm just trying
    >> to find a more efficient method. Thank you.
    >
    >
    >.
    >
    Andrea Worley Guest

Similar Threads

  1. preformatted HTML code from XSL by (C# based) ASP.NETobject?
    By mzanime.com in forum Macromedia Dynamic HTML
    Replies: 0
    Last Post: October 20th, 04:26 PM
  2. CF-based calendar code?
    By 4midori in forum Macromedia ColdFusion
    Replies: 3
    Last Post: March 12th, 07:19 PM
  3. Cache a user control based on a Property in the code behind.
    By MattC in forum ASP.NET Building Controls
    Replies: 3
    Last Post: February 24th, 09:33 AM
  4. What's the cursor code for a white arrow???
    By Nicollini webforumsuser@macromedia.com in forum Macromedia Director Lingo
    Replies: 4
    Last Post: September 8th, 08:52 PM
  5. perl code to test my C based CGI application
    By chris in forum PERL Miscellaneous
    Replies: 5
    Last Post: June 30th, 03:09 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