Badges

Types

Formats

Show Only

SQL Cursor Examples
https://mreschke.com/6/sql-cursor-examples
DECLARE @server as nvarchar(50), @sql as nvarchar(4000) DECLARE SharedServers CURSOR FORWARD_ONLY FOR SELECT server FROM .ebis_prod.dbo.SharedServerList OPEN SharedServers FETCH NEXT FROM SharedServers INTO @server BEGIN TRANSACTION SET @sql = '' WHILE FETCH_STATUS = 0 BEGIN IF (@server) '' BEGIN --One itteration of SQL goes HERE SET @sql = @sql INSERT INTO .dyna.dbo.TestTable (val1, val2) VALUES (''mReschke'', ''hi'') ' END FETCH NEXT FROM SharedServers INTO @server END exec sp_executesql @sql...
|
post #6 by mreschke Nov 13th 2007 (2741 views)
Showing 1 to 1 of 1 results