Professional Web Applications Themes

Have a problem with using cursors in SQL server enterprise manager - ASP.NET General

Have a problem with using cursors in SQL server enterprise manager. My code sql query is followed --------------------------------------- DECLARE element_name varchar(100) DECLARE elements_cursor CURSOR FOR SELECT element_name FROM KB_Element_Ref OPEN elements_cursor FETCH NEXT FROM elements_cursor INTO element_name WHILE FETCH_STATUS = 0 BEGIN PRINT element_name FETCH NEXT FROM elements_cursor INTO element_name END CLOSE elements_cursor DEALLOCATE elements_cursor ------------------------------------------------------------ I have more than 100 rows int KB_Element_Ref table. but when I execute this query, it said only a row has affected and did't print any element_name. does any one know what is going on? *** Sent via Developersdex [url]http://www.developersdex.com[/url] *** Don't just participate ...

  1. #1

    Default Have a problem with using cursors in SQL server enterprise manager

    Have a problem with using cursors in SQL server enterprise manager.
    My code sql query is followed
    ---------------------------------------
    DECLARE element_name varchar(100)
    DECLARE elements_cursor CURSOR FOR
    SELECT element_name
    FROM KB_Element_Ref

    OPEN elements_cursor
    FETCH NEXT FROM elements_cursor INTO element_name

    WHILE FETCH_STATUS = 0
    BEGIN
    PRINT element_name
    FETCH NEXT FROM elements_cursor INTO element_name
    END

    CLOSE elements_cursor
    DEALLOCATE elements_cursor
    ------------------------------------------------------------
    I have more than 100 rows int KB_Element_Ref table.
    but when I execute this query, it said only a row has affected and did't
    print any element_name.
    does any one know what is going on?


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    TaeHo Yoo Guest

  2. #2

    Default Re: Have a problem with using cursors in SQL server enterprise manager

    your code is correct

    are you sure the table is not empty?

    Vaclav

    "TaeHo Yoo" <anonymousdevdex.com> wrote in message
    news:uNMxxf6ODHA.3152TK2MSFTNGP10.phx.gbl...
    > Have a problem with using cursors in SQL server enterprise manager.
    > My code sql query is followed
    > ---------------------------------------
    > DECLARE element_name varchar(100)
    > DECLARE elements_cursor CURSOR FOR
    > SELECT element_name
    > FROM KB_Element_Ref
    >
    > OPEN elements_cursor
    > FETCH NEXT FROM elements_cursor INTO element_name
    >
    > WHILE FETCH_STATUS = 0
    > BEGIN
    > PRINT element_name
    > FETCH NEXT FROM elements_cursor INTO element_name
    > END
    >
    > CLOSE elements_cursor
    > DEALLOCATE elements_cursor
    > ------------------------------------------------------------
    > I have more than 100 rows int KB_Element_Ref table.
    > but when I execute this query, it said only a row has affected and did't
    > print any element_name.
    > does any one know what is going on?
    >
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    Vaclav Jedlicka Guest

  3. #3

    Default Re: Have a problem with using cursors in SQL server enterprise manager

    Try
    <CODE>
    DECLARE element_name varchar(100)
    DECLARE elements_cursor CURSOR FOR SELECT element_name FROM
    KB_Element_Ref

    SELECT COALESCE(element_name,'Null Value') FROM KB_Element_Ref

    OPEN elements_cursor
    FETCH NEXT FROM elements_cursor INTO element_name
    WHILE FETCH_STATUS = 0

    BEGIN
    PRINT '<<' + element_name + '>>'
    FETCH NEXT FROM elements_cursor INTO element_name
    END

    CLOSE elements_cursor
    DEALLOCATE elements_cursor
    </CODE>

    in query yzer to help check if a zero length string, or null is
    being returned.


    Rhys Gravell

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Rhys Gravell Guest

Similar Threads

  1. Settings Manager in the Enterprise
    By ely67241 in forum Macromedia Flash Player
    Replies: 0
    Last Post: November 16th, 07:39 PM
  2. Enterprise Manager disappeared from CF Administrator
    By danteorlando in forum Coldfusion Server Administration
    Replies: 2
    Last Post: June 10th, 01:06 AM
  3. Replies: 2
    Last Post: July 18th, 12:30 AM
  4. ASP enterprise manager ?
    By Jurjen de Groot in forum ASP.NET General
    Replies: 3
    Last Post: July 11th, 08:43 PM
  5. Enterprise Manager Problem
    By Peter Cwik in forum Microsoft SQL / MS SQL Server
    Replies: 4
    Last Post: July 9th, 10:29 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
  •  

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