30.06.2013 Views

SQL Server Execution Plans - Red Gate Software

SQL Server Execution Plans - Red Gate Software

SQL Server Execution Plans - Red Gate Software

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 6: Cursor Operations<br />

can easily see how changes to cursor properties affect the execution plans. The data is<br />

returned as multiple result sets, as shown in Figure 6.1.<br />

DECLARE CurrencyList CURSOR<br />

FOR<br />

SELECT CurrencyCode<br />

FROM Sales.Currency<br />

WHERE Name LIKE '%Dollar%'<br />

OPEN CurrencyList<br />

FETCH NEXT FROM CurrencyList<br />

WHILE @@FETCH_STATUS = 0<br />

BEGIN<br />

-- Normally there would be operations here using data from cursor<br />

END<br />

FETCH NEXT FROM CurrencyList<br />

CLOSE CurrencyList<br />

DEALLOCATE CurrencyList<br />

GO<br />

Listing 6.1<br />

Figure 6.1<br />

228

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!