SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Harnessing SQL Server Metadata- Disabling and Rebuilding Indexes


Harnessing SQL Server Metadata- Disabling and Rebuilding Indexes

Author
Message
Joshua Feierman
Joshua Feierman
Old Hand
Old Hand (313 reputation)Old Hand (313 reputation)Old Hand (313 reputation)Old Hand (313 reputation)Old Hand (313 reputation)Old Hand (313 reputation)Old Hand (313 reputation)Old Hand (313 reputation)

Group: General Forum Members
Points: 313 Visits: 304
Comments posted to this topic are about the item Harnessing SQL Server Metadata- Disabling and Rebuilding Indexes

Senior DBA - Gateway Ticketing Systems
Co-Founder - Do It Simply Software

Follow me at http://sqljosh.com
Iwas Bornready
Iwas Bornready
One Orange Chip
One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)

Group: General Forum Members
Points: 29240 Visits: 885
Makes total sense, good to know. Thanks.
g.britton
g.britton
SSCarpal Tunnel
SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)

Group: General Forum Members
Points: 4959 Visits: 1763
In the WHERE clause you have:

(sobj.name = @i_Table_Name or @i_Table_Name = '')



Since @i_Table_Name is defined as sysname, you might want to use N'' instead of just ''.

BTW did you consider using

(sobj.name like @i_Table_Name  )



instead, thus allowing for wildcards and then covering the empty string with N'%' instead of just N''?

I often find that explicit is better than implicit.

Gerald Britton, MCSE-DP, MVP
Toronto PASS Chapter
Joshua Feierman
Joshua Feierman
Old Hand
Old Hand (313 reputation)Old Hand (313 reputation)Old Hand (313 reputation)Old Hand (313 reputation)Old Hand (313 reputation)Old Hand (313 reputation)Old Hand (313 reputation)Old Hand (313 reputation)

Group: General Forum Members
Points: 313 Visits: 304
Hi Gerald, two excellent suggestions, which I'll implement.

Senior DBA - Gateway Ticketing Systems
Co-Founder - Do It Simply Software

Follow me at http://sqljosh.com
pcindex
pcindex
Grasshopper
Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)

Group: General Forum Members
Points: 12 Visits: 202
will this enable ALL disabled indexes?

if so, there is a flaw, as if we already have a few disabled indexes (out of use)
and we try the disable/re-enable routine,
it will re-enable those ("out of use") ones too.

we somehow need to "save" which ones we are disabling in the routine,
and then re-enable just those.

regards,
Makis
Joshua Feierman
Joshua Feierman
Old Hand
Old Hand (313 reputation)Old Hand (313 reputation)Old Hand (313 reputation)Old Hand (313 reputation)Old Hand (313 reputation)Old Hand (313 reputation)Old Hand (313 reputation)Old Hand (313 reputation)

Group: General Forum Members
Points: 313 Visits: 304
Hi Makis,

That's an interesting suggestion. I'll have to think about that one a bit, as it would require having a table somewhere where the indexes that the procedure initially disables are stored, and I was trying to avoid having any footprint beyond a procedure. Do you envision it as keeping that information stored until you run it in enable mode, then deleting it? What about if multiple processes are calling it at the same time, say for different databases or sets of tables; how do you think it should handle that?

Thanks for the feedback in any case.

-Josh

Senior DBA - Gateway Ticketing Systems
Co-Founder - Do It Simply Software

Follow me at http://sqljosh.com
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search