change cursor code to set based code

Ask a Question related to Microsoft SQL / MS SQL Server, Design and Development.

  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_rage@hotmail.com> wrote in message
    news:089901c34559$5c6cb5a0$a001280a@phx.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. Similar Questions and Discussions

    1. preformatted HTML code from XSL by (C# based) ASP.NETobject?
      Hi, sorry for the long-winded message title. I'm working with other peoples code. My outputted HTML code, after its been transformed through XSL...
    2. CF-based calendar code?
      Hi, I am looking for some simple code that will generate a monthly HTML-based calendar with back/forward for each month. Something exceedingly...
    3. Cache a user control based on a Property in the code behind.
      I have a user control that is placed on every page to provide a menu system, logout/login buttons etc. This contect varies in depending on the...
    4. What's the cursor code for a white arrow???
      Does anyone know the anwser to the above question? Thanks. Nick
    5. perl code to test my C based CGI application
      Already tried cgi newsgroup to no avail. I'm a Perl begginner, and it's starting to look like Perl is the best way to do this. I have a C based...
  3. #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_rage@hotmail.com> wrote in message
    >news:089901c34559$5c6cb5a0$a001280a@phx.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

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