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