Ok. Here's a cut and paste example from the templates in Query Analyzer. Don't blame me if you use this though. :)
-- =============================================
-- Declare and using a READ_ONLY cursor
-- =============================================
DECLARE names1 CURSOR
READ_ONLY
FOR SELECT au_fname FROM pubs.dbo.authors
DECLARE @name varchar(40)
OPEN names1
FETCH NEXT FROM names1 INTO @name
WHILE (@@fetch_status <> -1)
BEGIN
IF (@@fetch_status <> -2)
BEGIN
-- PRINT 'add user defined code here'
-- eg.
DECLARE @message varchar(100)
SELECT @message = 'my name is: ' + @name
PRINT @message
-- =============================================
-- Declare and using a KEYSET cursor
-- =============================================
DECLARE names2 CURSOR
KEYSET
FOR SELECT au_fname FROM pubs.dbo.authors
DECLARE @name1 varchar(40)
OPEN names2
FETCH NEXT FROM names2 INTO @name1
WHILE (@@fetch_status <> -1)
BEGIN
IF (@@fetch_status <> -2)
BEGIN
-- PRINT 'add user defined code here'
-- eg.
PRINT 'updating record for ' + @name1
UPDATE pubs.dbo.authors
SET phone = replace(phone, ' ', '-')
WHERE CURRENT OF names2
END
FETCH NEXT FROM names2 INTO @name1
END
CLOSE names2
DEALLOCATE names2
END
FETCH NEXT FROM names1 INTO @name
END
CLOSE names1
DEALLOCATE names1
GO
MeanOldDBA
derrickleggett@hotmail.com
When life gives you a lemon, fire the DBA.