Another video brought to you by BeardedDev, bringing you tutorials on Data Engineering, Business Intelligence, T-SQL Programming and Data Analysis.
If you like the video you can support me on Patreon, / beardeddev
Prerequisites
Check out this link to install Adventure Works Database: https://docs.microsoft.com/en-us/sql/...
In this SQL tutorial I talk through what SCHEMABINDING is and how it can be used within views, SCHEMABINDING is not specific to views and can be used within other objects but is most commonly associated with views.
Do you ever get this error on views? Could not use view or function because of binding errors then this tutorial will help by implementing SCHEMABINDING within a view.
Code Samples - this is not complete but you can copy and paste and change as necessary
IF OBJECT_ID(N'Sales.SalesOrderHeaderCopy', N'U') IS NOT NULL
BEGIN
DROP TABLE Sales.SalesOrderHeaderCopy
END
SELECT
*
INTO Sales.SalesOrderHeaderCopy
FROM Sales.SalesOrderHeader;
ALTER VIEW Sales.vwSalesHeader
WITH SCHEMABINDING
AS
SELECT
SalesOrderID AS SalesOrderID,
OrderDate,
SalesOrderNumber,
CustomerID,
TotalDue
FROM Sales.SalesOrderHeaderCopy;
SELECT
*
FROM Sales.vwSalesHeader;
ALTER TABLE Sales.SalesOrderHeaderCopy
DROP COLUMN SalesOrderNumber;