USE pubs DECLARE tnames_cursor CURSOR FOR SELECT state FROM authors open tnames_cursor declare@statevarchar(50) Fetch tnames_cursor into@state while (@@fetch_status=0) begin if(@state='CA') begin print'sd' end FETCHNEXTFROM tnames_cursor INTO@state end CLOSE tnames_cursor DEALLOCATE tnames_cursor