dump all your answers into a recordset on the client and walk through them at your leisure) As far as posting an alternative select identityCol, ( columnA * 0.0325) from myTable I think that the problem will be finding an example of when set theory fails. (If you have one there is probably a branch of mathematics where some graduate student is playing with the problem properties tonight) with your example tonight) "Mark Dowell" wrote in message news:O1HVFVASDHA.2116@TK2MSFTNGP12.phx.gbl...[quote] > Hello, > > I was wondering if there is a way to iterate through a > sql result set without using cursors within a stored procedure. > > Since everyone loves to bash cursors, I was wondering > if someone could post an alternative example. > > Thanks > >[/quote] [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => <#FljcgLSDHA.3768@tk2msftngp13.phx.gbl> [ref] => [htmlstate] => on_nl2br [postusername] => Jay Schmitendorf [ip] => jayschmitendorf [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 4 [islastshown] => 1 [isfirstshown] => [attachments] => [allattachments] => ) --> Iterate without a Cursor - Microsoft SQL / MS SQL Server

Iterate without a Cursor - Microsoft SQL / MS SQL Server

Here is a small example on northwind database. use northwind go declare x varchar(500) select x='0' while x is not null begin select x=min(customerid) from customers where customerid > x print x end -- -Vishal "Mark Dowell" <markdowellmsn.com> wrote in message news:O1HVFVASDHA.2116TK2MSFTNGP12.phx.gbl... > Hello, > > I was wondering if there is a way to iterate through a > sql result set without using cursors within a stored procedure. > > Since everyone loves to bash cursors, I was wondering > if someone could post an alternative example. > > Thanks > >...

  1. #1

    Default Re: Iterate without a Cursor

    Here is a small example on northwind database.
    use northwind
    go
    declare x varchar(500)
    select x='0'
    while x is not null
    begin
    select x=min(customerid) from customers
    where customerid > x
    print x
    end

    --
    -Vishal
    "Mark Dowell" <markdowellmsn.com> wrote in message
    news:O1HVFVASDHA.2116TK2MSFTNGP12.phx.gbl...
    > Hello,
    >
    > I was wondering if there is a way to iterate through a
    > sql result set without using cursors within a stored procedure.
    >
    > Since everyone loves to bash cursors, I was wondering
    > if someone could post an alternative example.
    >
    > Thanks
    >
    >

    Vishal Parkar Guest

  2. #2

    Default Re: Iterate without a Cursor

    The alternative to a cursor is usually set-based SELECT/UPDATE/INSERT/DELETE
    statements. Row-by-row processing should be avoided where possible whether
    in a cursor or otherwise. Why do you want to iterate through a result set?

    --
    David Portas
    ------------
    Please reply only to the newsgroup
    --

    "Mark Dowell" <markdowellmsn.com> wrote in message
    news:O1HVFVASDHA.2116TK2MSFTNGP12.phx.gbl...
    > Hello,
    >
    > I was wondering if there is a way to iterate through a
    > sql result set without using cursors within a stored procedure.
    >
    > Since everyone loves to bash cursors, I was wondering
    > if someone could post an alternative example.
    >
    > Thanks
    >
    >

    David Portas Guest

  3. #3

    Default Re: Iterate without a Cursor

    Mark,

    Have you considered using a "Derived" table? This approach may enable you
    to accomplish what you want to do.

    J.R.
    Largo SQL Tools
    The Finest Collection of SQL Tools Available
    [url]http://www.largosqltools.com[/url]

    "Mark Dowell" <markdowellmsn.com> wrote in message
    news:O1HVFVASDHA.2116TK2MSFTNGP12.phx.gbl...
    > Hello,
    >
    > I was wondering if there is a way to iterate through a
    > sql result set without using cursors within a stored procedure.
    >
    > Since everyone loves to bash cursors, I was wondering
    > if someone could post an alternative example.
    >
    > Thanks
    >
    >

    Largo SQL Tools Guest

  4. #4

    Default Re: Iterate without a Cursor

    I think that the definition of cursor is a mechanism that iterates
    so the answer is no. If there was it would be labeled a 'oddball' cursor.

    However there are always, or almost always, unique projections on a table,
    to your answer space or the database would not be normalized.
    If not relationaly normalized then mathematically normalized.

    There should be a set function that pumps out a result set that already
    has your answer.
    You only should have to iterate through the answers.
    Which might be your real question,(which if so then --> dump all your
    answers
    into a recordset on the client and walk through them at your leisure)

    As far as posting an alternative
    select identityCol, ( columnA * 0.0325) from myTable

    I think that the problem will be finding an example of when set theory
    fails.
    (If you have one there is probably a branch of mathematics where some
    graduate student is playing with the problem properties tonight)
    with your example tonight)


    "Mark Dowell" <markdowellmsn.com> wrote in message
    news:O1HVFVASDHA.2116TK2MSFTNGP12.phx.gbl...
    > Hello,
    >
    > I was wondering if there is a way to iterate through a
    > sql result set without using cursors within a stored procedure.
    >
    > Since everyone loves to bash cursors, I was wondering
    > if someone could post an alternative example.
    >
    > Thanks
    >
    >

    Jay Schmitendorf Guest

Similar Threads

  1. Iterate through open doents
    By Deelip Menezes in forum Adobe Acrobat SDK
    Replies: 2
    Last Post: November 17th, 05:17 AM
  2. iterate through a dataset
    By dave in forum Macromedia Flash Data Integration
    Replies: 0
    Last Post: April 2nd, 03:10 PM
  3. iterate through POSTed variables
    By Ike in forum PHP Development
    Replies: 8
    Last Post: August 12th, 09:10 PM
  4. iterate through bound columns
    By Jim Corey in forum ASP.NET Data Grid Control
    Replies: 3
    Last Post: September 30th, 09:43 AM
  5. cursor 200-problem on mac but not pc? how to swap cursor image?
    By nickelsock webforumsuser@macromedia.com in forum Macromedia Director Lingo
    Replies: 5
    Last Post: August 2nd, 10:58 AM

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
  •