Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Error creating a View

Author  Topic 

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-02-23 : 11:20:31
I already posted this as part of another one of my threads...thats not really related to Views...so creating a new one here for a quicker solution

CREATE VIEW [dbo].[NALK_RELA_KEY] with schemabinding AS
(SELECT SUBSTRING(NALK_KEY0,34,8) AS NALK_ADDRESS_ID,
SUBSTRING(NALK_KEY0,1,8) AS NALK_RELA_KEY,
NAME_ID,
NALK_KEY0,
RANK() OVER (PARTITION BY NAME_ID ORDER BY EFFECTIVE_DATE DESC, ADDRESS_ID DESC) AS RANK1
FROM [dbo].[PNALK] WITH (NOLOCK)
WHERE ADDRESS_ID <> 0 AND EFFECTIVE_DATE <= CONVERT(char, GETDATE(),112));

CREATE UNIQUE CLUSTERED INDEX NALK_RELA_KEY on [dbo].[NALK_RELA_KEY](NALK_KEY0)

I get the following error..cannot create index "because the view contains a table hint. Consider removing the hint."

Not sure what the error means...any help

raky
Aged Yak Warrior

767 Posts

Posted - 2009-02-23 : 11:36:53
Remove with (nolock) condition in the from clause
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-02-23 : 11:38:04
Remove the hint. (with nolock)
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-02-23 : 11:53:21
Thanks...I removed the (NOLOCK), now it fails again saying it contains a RANK() and hence cannot create an Index. Can i get over this?
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-02-23 : 12:00:03
See rules to create indexed views. There are many restrictions for it.Check in Booksonline.
Go to Top of Page
   

- Advertisement -