Back to Browse

How To Write SQL Server Queries Correctly: Views vs Inline Table Valued Functions

1.3K views
Dec 20, 2024
22:23

In this video, I delve into the world of views and inline table-valued functions in SQL Server, exploring how these database objects can be both a blessing and a curse depending on their usage. I discuss common pitfalls that arise when people misuse views, leading to performance issues due to excessive nesting and overly complex queries. Additionally, I highlight the advantages of inline table-valued functions, particularly their ability to accept parameters, which can help push predicates further into queries for better optimization. The video also covers a specific issue with views inside stored procedures versus using literal values directly, and how Microsoft addressed this problem in later SQL Server versions through query optimizer hot fixes. By sharing practical examples and solutions, I aim to provide viewers with insights on when and how to effectively use these database objects to enhance their SQL skills. CHAPTERS 00:00:00 - Introduction to Views and Inline Table Valued Functions 00:03:15 - Simple Query with Literal Value 00:06:48 - Parameterized Query without Fixes 00:12:19 - Using Compatibility Level Hint for Better Performance 00:17:16 - Inline Table Valued Function Example 00:21:04 - Summary and Next Video ━━━━━━━━━━━━━━━━━━━━━━━━━━ 📚 TRAINING & COURSES ━━━━━━━━━━━━━━━━━━━━━━━━━━ Get AI-Ready With Erik https://training.erikdarling.com/get-ai-ready-with-erik?coupon=AIREADY SQL Server Performance Engineering Course https://training.erikdarling.com/sql-server-performance-engineering?coupon=ENGINEERING Learn T-SQL with Erik https://training.erikdarling.com/learn-t-sql-with-erik?coupon=ADVANCEDTSQL Everything Bundle: https://training.erikdarling.com/?coupon=SPRINGCLEANING ━━━━━━━━━━━━━━━━━━━━━━━━━━ 🛠️ CONSULTING & SERVICES ━━━━━━━━━━━━━━━━━━━━━━━━━━ Need SQL Server performance help? https://training.erikdarling.com/sqlconsulting ━━━━━━━━━━━━━━━━━━━━━━━━━━ 💬 CONNECT ━━━━━━━━━━━━━━━━━━━━━━━━━━ Ask questions at Office Hours https://erikdarling.com/officehours/ Become a channel member https://www.youtube.com/@ErikDarlingData/join ━━━━━━━━━━━━━━━━━━━━━━━━━━

Download

1 formats

Video Formats

360pmp453.3 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

How To Write SQL Server Queries Correctly: Views vs Inline Table Valued Functions | NatokHD