This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| IF OBJECT_ID ( 'dbo.fb', 'P' ) IS NOT NULL | |
| drop procedure dbo.fb; | |
| GO | |
| CREATE PROCEDURE dbo.fb (@int int) | |
| AS | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --show stats on table reads/writes | |
| Select | |
| object_schema_name(UStat.object_id) + '.' + object_name(UStat.object_id) As [Object Name], | |
| Case | |
| When sum(User_Updates + User_Seeks + User_Scans + User_Lookups) = 0 | |
| Then Null | |
| Else convert(decimal(5,2),round(Cast(sum(User_Seeks + User_Scans + User_Lookups) As Decimal) | |
| / Cast(sum(User_Updates |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --save PRE stats on index fragmentation | |
| IF OBJECT_ID('tempdb..#tmp_PRE_reindex', 'U') IS NOT NULL DROP TABLE #tmp_PRE_reindex | |
| SELECT | |
| ROW_NUMBER() over (order by sDips.index_id) as 'rowid', | |
| OBJECT_NAME(sDips.OBJECT_ID) as 'objid', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --assumes default IIS/ASP.net timeout of 20 minutes | |
| select | |
| row_number() over (partition by cusername order by cusername) as [count] | |
| , cUserName, tLogin, cApplication, cmachinename | |
| from log | |
| where DATEDIFF(MINUTE, tlogin, CURRENT_TIMESTAMP) < 20 | |
| and lSuccess = 1 | |
| and tLogout = '' | |
| order by tLogin desc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sp_configure 'Ole Automation Procedures', 1; | |
| RECONFIGURE | |
| GO | |
| CREATE FUNCTION dbo.RegexReplace | |
| ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --------------------------------------------------------------------------------------------------------------------------------------- | |
| --------------------------------------------------------------------------------------------------------------------------------------- | |
| --------------------------------------------------------------------------------------------------------------------------------------- | |
| --------------------------------------------------------------------------------------------------------------------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # i dont remember if i wrote this, or took it from somewhere | |
| select | |
| month_number, | |
| day_number, | |
| hour_number, | |
| isnull(d.data,0) | |
| FROM | |
| ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # this still needs some work | |
| --save PRE stats on index fragmentation | |
| IF OBJECT_ID('tempdb..#tmp_PRE_reindex', 'U') IS NOT NULL DROP TABLE #tmp_PRE_reindex | |
| SELECT | |
| ROW_NUMBER() over (order by sDips.index_id) as 'rowid', | |
| OBJECT_NAME(sDips.OBJECT_ID) as 'objid', | |
| si.name, | |
| sDips.index_id, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| echo "Retaining lookup tables <BR /><BR />"; | |
| /////////////////////////////////////////////////////////////////////////////////////// | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # i dont remember what this is for | |
| ---- | |
| EXEC sp_configure 'show advanced options', 1 | |
| GO | |
| RECONFIGURE | |
| GO | |
| EXEC sp_configure 'xp_cmdshell', 1 |
OlderNewer