March 27, 2009 at 12:44 pm
I need to add four un-clustered indexes to this table to the fields sdan8, sdkcoo, sddcto, sdlnid and sddoco, but I'm not sure how the syntax go. The table is below.
Table #tempSales
sdan8,
sdkcoo,
sddcto,
sdlnid,
sdtorg,
sddoco,
sdlitm,
sdsoqs,
sdaexp
Also, can I have un-clustered indexes on temp tables or do I need to create a physical one.
thx,
John
March 27, 2009 at 1:30 pm
You can create clustered and nonclustered indexes on temp tables.
Syntax is like this:
CREATE INDEX myindexname ON schemaname.tablename(col1,col2)
INCLUDE (col3)
WITH FILLFACTOR=80
ON Primary
That creates an index consisting of two columns which includes a column, alters the default fill factor and places it on the primary file group. You don't need to do all that every time. Check out the Books Online for details.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply