Codehelper, has given great links that you should read also
Firstly the thing that you need to be aware of is that
cursors
can be an expensive operation and should be avoided where possible.
An example Cursor is as follows
DECLARE @TableName VARCHAR(2000)
DECLARE db CURSOR FOR
SELECT name
FROM sysobject
WHERE xtype = 'u'
OPEN DB
FETCH NEXT FROM db INTO @TableName
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT @TableName
FETCH NEXT FROM db INTO @TableName
END
CLOSE db
DEALLOCATE db
Can we use Cursors with out create Procedure - YES