Click here to Skip to main content
15,897,291 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to update the values set in the cursor, inside a while loop, below is my sql query that give error in the statement "
SQL
update filteredCommunities
                set SearchStaticCount

"plz help i want to update only cursor values
following is the query
SQL
declare @loopCounter int
set @loopCounter=0
Declare @Community as varchar(30)
Declare @Counter as int

Declare filteredCommunities CURSOR FOR 
select SearchStaticCount,Keyword from SearchStatic ss inner join UnitListing us on ss.Keyword=us.UnitListingName  where ServiceTypeId='Sell' and CategoryTypeId='Commercial' 
for update of SearchStaticCount
OPEN filteredCommunities
    FETCH NEXT FROM filteredCommunities INTO @Counter,@Community
	        WHILE(@loopCounter<10)
        BEGIN
		        update filteredCommunities
				set SearchStaticCount=@loopCounter           
 				FETCH NEXT FROM filteredCommunities INTO @Counter,@Community
        END
CLOSE filteredCommunities
DEALLOCATE filteredCommunities
Posted
Updated 3-May-14 7:07am
v2
Comments
Maciej Los 3-May-14 13:09pm    
What error message?

1 solution

Please, read my caomment to the question.

The statement
SQL
UPDATE TableName SET FieldName = FieldValue

will update all data (for entire table).

To update single record:
SQL
UPDATE TableName SET FieldName = FieldValue WHERE UniqueField=UniqueValue
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900