In this chapter, we will discuss some fundamental techniques in T-SQL which will become useful in later chapters, when we discuss how to use PowerShell to automate your SQL Server enterprise. Specifically, we will discuss how to use the APPLY operator to call a function against rows within a result set. It is important to understand this technique in Chapter 8 , when we begin to look at metadata-driven automation. We will then look at how XML (eXtensible Markup Language) and how the native XML data type can be harnessed by SQL Server DBAs. It is critical for DBAs to have a handle on the use of XML, due to the volume of information, such as Query Plans, that is stored in this format. Understanding basic XML in SQL Server is also key to understanding how to loop efficiently. To this end, we will explore how to efficiently iterate through multiple objects, using an XML technique. We will compare its efficiency to that of a traditional cursor. This is important, because although looping in PowerShell is always more efficient, there are times where the optimal approach to automation will involve multiple layers of looping, through the PowerShell and T-SQL layers. This will become apparent in Chapter 8 , but the technique is used in multiple chapters throughout the book.

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

T-SQL Techniques for DBAs

  • Peter A. Carter

摘要

In this chapter, we will discuss some fundamental techniques in T-SQL which will become useful in later chapters, when we discuss how to use PowerShell to automate your SQL Server enterprise. Specifically, we will discuss how to use the APPLY operator to call a function against rows within a result set. It is important to understand this technique in Chapter 8 , when we begin to look at metadata-driven automation. We will then look at how XML (eXtensible Markup Language) and how the native XML data type can be harnessed by SQL Server DBAs. It is critical for DBAs to have a handle on the use of XML, due to the volume of information, such as Query Plans, that is stored in this format. Understanding basic XML in SQL Server is also key to understanding how to loop efficiently. To this end, we will explore how to efficiently iterate through multiple objects, using an XML technique. We will compare its efficiency to that of a traditional cursor. This is important, because although looping in PowerShell is always more efficient, there are times where the optimal approach to automation will involve multiple layers of looping, through the PowerShell and T-SQL layers. This will become apparent in Chapter 8 , but the technique is used in multiple chapters throughout the book.