November 3, 2012 at 5:28 am
I want to create non clustered index on a view to check the limit that how many non clustered index can be created on a view. To do that I write a query but its not working and showing error:
declare @a int=2
while @a<2056
create nonclustered index ('testindex' + @a) on dbo.[item_vw]
(
order_no
)
set @a=@a+1
plz suggest..
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
November 3, 2012 at 10:03 am
kapil_kk (11/3/2012)
I want to create non clustered index on a view to check the limit that how many non clustered index can be created on a view. To do that I write a query but its not working and showing error:declare @a int=2
while @a<2056
create nonclustered index ('testindex' + @a) on dbo.[item_vw]
(
order_no
)
set @a=@a+1
plz suggest..
You'll need to change the whole CREATE statement to dynamic SQL and the execute the dynamic SQL.
--Jeff Moden
Change is inevitable... Change for the better is not.
November 4, 2012 at 11:23 pm
Jeff,
I dont have any idea about dynamic SQL so can you plz help me in this...
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
November 5, 2012 at 12:29 am
declare @a int=1
declare @lsql nvarchar(300)
set @lsql = ''
while @a<2056
begin
set @lsql = ''
set @lsql = 'create nonclustered index testindex_' + cast (@a as nvarchar(100)) + ' on dbo.[item_vw] (order_no) '
print @lsql
exec (@lsql )
set @a=@a+1
end i havent tried this but it should work.
-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
November 12, 2012 at 3:49 am
November 12, 2012 at 5:21 am
Artoo22 (11/12/2012)
kapil_kk (11/3/2012)
I want to create non clustered index on a view to check the limit that how many non clustered index can be created on a view.Why?
i think it's the difference between reading about the maximum number of indexes(999), and actually experiencing the errors you get when you create index 1000;
it makes you a better developer or DBA when you truly understand a boundary or limitation.
plus the headaches you go through creating an indexed view...I can definitely relate.
Lowell
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply