/ Published in: SQL
Minimal syntax for cursor use. See URL for SQL 2005 options and improvements.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
DECLARE @EntityName AS VARCHAR(100) DECLARE DepNameCursor Cursor FAST_FORWARD FOR SELECT top 100 MailName FROM DepNameExt OPEN DepNameCursor FETCH NEXT FROM DepNameCursor INTO @EntityName WHILE @@Fetch_Status = 0 BEGIN INSERT INTO [UDC].[dbo].[Entity] ([Name]) VALUES (@EntityName) FETCH NEXT FROM DepNameCursor INTO @EntityName END CLOSE DepNameCursor DEALLOCATE DepNameCursor
URL: http://msdn.microsoft.com/en-us/library/ms190028.aspx