Have a problem with using cursors in SQL server enterprise manager

Ask a Question related to ASP.NET General, Design and Development.

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

    1. Enterprise Manager Errors on UNIX
      CFMX 7.0.1 multiserver configuration on UNIX (Solaris 9). When creating a new instance in CFAdmin Enterprise Manager Instance Manager I get the...
    2. Settings Manager in the Enterprise
      Where are the settings stored when the web tool is used to adjust local flash player settings? For example: the auto update is turned off or the...
    3. Can't connect to remote sql server from asp.net buk ok from Enterprise Manager
      Remove now aspnet user from admin group! (no matter is a test server, is a bad practique). You server is win2003? I don't can connect to Sql Server...
    4. ASP enterprise manager ?
      Has anyone tried the ASP.NET Enterprise Manager ? I've installed it but after starting up it produces errors, I've started it by using...
    5. Enterprise Manager Problem
      I can connect fine via query analyzer, but it takes several minutes to expand the databases on one particular server. Other servers, database...
  3. #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" <anonymous@devdex.com> wrote in message
    news:uNMxxf6ODHA.3152@TK2MSFTNGP10.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

  4. #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 analyzer 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

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