Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
228 views
in Technique[技术] by (71.8m points)

sql server - Cannot schema bind view MyName' because name MyTable is invalid for schema binding

I am trying to create an indexed view in SQL Server 2012 on a query that has 10 joins (inner and left), which is accessed a lot.

However, when attempting to create the view, I get an error:

Cannot schema bind view 'vw_transaction' because name 'entity_event' is invalid for schema binding.

I am (attempting to) create the view using:

CREATE VIEW vw_transaction WITH SCHEMABINDING AS
    Select ee.id as entity_event_id,
        ....

Is there a reason for this error? It looks like it's a reserved word, as the error mentions a 'name', as opposed to a column. Entity_event is the name of my main table.

question from:https://stackoverflow.com/questions/24226584/cannot-schema-bind-view-myname-because-name-mytable-is-invalid-for-schema-bindi

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I fixed the issue by adding the schema name in front of all table references:

select [..] from schema_name.table_name

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

Just Browsing Browsing

[4] html - How to create even cell spacing within a

1.4m articles

1.4m replys

5 comments

56.9k users

...