Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Have a problem with using cursors in SQL server enterprise manager

Reply
Thread Tools

Have a problem with using cursors in SQL server enterprise manager

 
 
TaeHo Yoo
Guest
Posts: n/a
 
      06-26-2003
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 http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
 
Vaclav Jedlicka
Guest
Posts: n/a
 
      06-26-2003
your code is correct

are you sure the table is not empty?

Vaclav

"TaeHo Yoo" <> wrote in message
news:...
> 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 http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



 
Reply With Quote
 
 
 
 
Rhys Gravell
Guest
Posts: n/a
 
      06-26-2003
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 http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What Happened to Sql Enterprise Manager and Sql Query Analyser in Visual Studio 2005 Edward ASP .Net 4 04-10-2006 04:15 PM
Web hosting and SQL Server Enterprise Manager? John ASP .Net 7 04-05-2005 01:19 PM
Web hosting with SQL Server Enterprise Manager? infoplease NZ Computing 3 04-05-2005 12:45 PM
Re: Can't connect to remote sql server from asp.net buk ok from Enterprise Manager bruce barker ASP .Net 0 07-18-2003 12:30 AM
Re: Can't connect to remote sql server from asp.net buk ok from Enterprise Manager Mamcx ASP .Net 1 07-18-2003 12:15 AM



Advertisments
 



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