Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

What is the meaning of view is not schema bound? Expand / Collapse
Author
Message
Posted Monday, September 10, 2012 4:06 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, December 31, 2013 2:00 AM
Points: 21, Visits: 150

Dear All,

I have created following view named FDIP_ITEMS :-

CREATE VIEW FDIP_ITEM AS
SELECT DISTINCT A.ROWID,A.A_CODE,A.I_CODE,'P02' PHP,'NOS' UNIT FROM PHP_STOCK A WHERE PEND_QTY>0
UNION ALL
SELECT DISTINCT ROWID,A_CODE,I_CODE,'' PHP,'NOS' UNIT FROM FDIP_RMSTK

It is taking 2 minutes to out result so i want to create index on a_code and i_code columns. But when i am creating index through SQL M.Studio it is showing following error:-
Cannot create index on view 'FDIP_ITEM' because the view is not schema bound. (Microsoft SQL Server, Error: 1939)

Tell me how to overcome this problem/error.

Please tell me where i am doing wrong and it is okey to create index on this view.

Regards

Neel



Post #1356625
Posted Monday, September 10, 2012 4:38 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 4:11 AM
Points: 42,994, Visits: 36,150
Read up on the requirements for indexing a view, there are a lot of them.

This particular one (as Books Online would have shown) say that the view was not created using WITH SCHEMABINDING. However you won't be able to index that anyway because DISTINCT is not allowed in an indexed view, neither is UNION.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1356640
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse