Mar 15, 2012

Cannot schema bind view '' because name '' is invalid for schema binding. Names must be in two-part format and an object cannot reference itself.


When we create view with SCHEMABINDING it is necessary to specify the schema name in objects name of SELECT statement. If we will execute following query:

CREATE VIEW view_StuInfo WITH SCHEMABINDING
AS
SELECT Age,Name FROM Student

We will get error message:

Cannot schema bind view 'view_StuInfo' because name 'Student' is invalid for schema binding. Names must be in two-part format and an object cannot reference itself.

Solution:

CREATE VIEW view_StuInfo WITH SCHEMABINDING
AS
SELECT Age,Name FROM dbo.Student

7 comments:

Anonymous said...

Thanks a lot..
You saved my day !!

Anonymous said...

mine too :)

thanx

Anonymous said...

Simple and helpful. Thanks! :D

Anonymous said...

Thanks!!

Anonymous said...

Muchas Gracias..!!! :D me ha funciona magnifico

[Rpiz] said...

hi.. how about [MYDB].[dbo].[MAINT_PASSDOWN]?
I need to query with DBname. Here is teh error:
Cannot schema bind view 'view_StuInfo' because name MYDB.dbo.MAINT_PASSDOWN' is invalid for schema binding.

Priyanka kumari said...

It is limitation of schema binding. You cannot bind the tables of different databases. You must have to specify only two part name of object like "Schema Name"."Table Name"

If all the tables are in the same database then you should create view in that database and then you can reference it in any database.