--declare a Cursor holding all vend_id and vend_name with vend_state NOT NULL
DECLARE vend_cursor CURSOR
FOR
SELECT vend_id, vend_name, vend_state
FROM Vendors
--WHERE Vend_State IS NOT NULL
ORDER BY vend_id

--declare two variables to hold the vend_id and vend_name
DECLARE @vend_id CHAR(10),
	@vend_name CHAR(50),
	@vend_state CHAR(10)
--open the cursor for processing
OPEN  vend_cursor

FETCH NEXT FROM vend_cursor
	INTO @vend_id, @vend_name, @vend_state
WHILE @@FETCH_STATUS = 0

BEGIN
--all user defined code to be inserted between the BEGIN and END
	PRINT RTRIM(@vend_id) + ' - ' + RTRIM(@vend_name)
	FETCH NEXT FROM vend_cursor
	INTO @vend_id, @vend_name, @vend_state
END
--close the current instance of the cursor
CLOSE vend_cursor

--deallocate the resources explicity for the Cursor
DEALLOCATE vend_cursor

--SELECT *
--FROM Vendors
--ORDER BY vend_id