It's stuff like this that pisses me off: You have to put the owner of the table in the sql statement. Like that's obvious...
USE Northwind
GO
CREATE VIEW vwEmployeeAgeSchemabinding ([Name], Age)
WITH SCHEMABINDING
AS
SELECT TitleOfCourtesy + ' ' + FirstName + ' ' + ' ' + LastName, DATEDIFF(yy, BirthDate, GETDATE())
FROM Employees2
GO
Output:
Server: Msg 4512, Level 16, State 3, Procedure vwEmployeeAgeSchemabinding, Line 4
Cannot schema bind view 'vwEmployeeAgeSchemabinding' because name 'Employees2' is invalid for schema binding. Names must be in two-part format and an object cannot reference itself.
Ooops, didn’t work did it? When using SCHEMABINDING, the select statement must include the two-part names (owner.object) of tables, views or user-defined functions referenced. So, let’s try this instead:
USE Northwind
GO
CREATE VIEW vwEmployeeAgeSchemabinding ([Name], Age)
WITH SCHEMABINDING
AS
SELECT TitleOfCourtesy + ' ' + FirstName + ' ' + ' ' + LastName, DATEDIFF(yy, BirthDate, GETDATE())
FROM dbo.Employees2
GO
Credit: http://www.ilopia.com/Articles/SQLServer/Views.aspx