Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
INDEXES (SQL Server 2000, 2005)
Old 06-05-2009, 02:05 PM INDEXES (SQL Server 2000, 2005)
Junior Talker

Posts: 4
Trades: 0
How to create a non clustered index that behaves like a clustered index?
splash!!! is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-05-2009, 02:36 PM Re: INDEXES (SQL Server 2000, 2005)
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Is this for real ?
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 06-05-2009, 02:57 PM Re: INDEXES (SQL Server 2000, 2005)
Junior Talker

Posts: 4
Trades: 0
Well, It is part of my assignment. Maybe a non-clustered index on a clustered table behaves similar to a clustered index?
splash!!! is offline
Reply With Quote
View Public Profile
 
Old 06-05-2009, 03:17 PM Re: INDEXES (SQL Server 2000, 2005)
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
No, it seems that you don't understand what a clustered index is...

Put simple, when you have a table with a non-clustered index, the rows are put in the order you insert them.
If your script insert rows with the order: "10,8,6,9,1,7,3,5,2,4", then inspecting the pages (physical allocation on disk) we would find the rows in that order.

If your table have an clutered index, then sql server will reorganize the rows upon insertion to put them in the order defined by the index.
So, if like previously, you insert the rows with the order "10,8,6,9,1,7,3,5,2,4", we would find them ordered from 1 to 10.

So, in my opinion, you cannot emulate an clustered index without a clustered index without having a serious performance hit.
The only solution I see would be to have a trigger that would fetch the whole table in a temp table, and redo an insert with a
Code:
insert into tableX(x, y, z)
select x,y,z 
from #tmpTable 
order by id
on each insert.

I cannot say that I'd encourage this....
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to INDEXES (SQL Server 2000, 2005)
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.66259 seconds with 12 queries