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:
Thanks a lot..
You saved my day !!
mine too :)
thanx
Simple and helpful. Thanks! :D
Thanks!!
Muchas Gracias..!!! :D me ha funciona magnifico
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.
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.
Post a Comment