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
/* | |
LOG STORED PROCEDURE RUN TIMES AND ERROR MESSAGES | |
Example: | |
==================== | |
-- Place at beginning of your stored procedure | |
DECLARE @Parameters VARCHAR(200) = NULL; | |
SET @Parameters = 'Account: ' + ISNULL(@Account,'') + ' UserID: ' + ISNULL(@UserID,''); | |
DECLARE @StartTime DATETIME = GETDATE(); | |
EXEC Call_ssProcedureLog @ObjectID = @@PROCID, @StartDate = @StartTime, @AdditionalInfo = @Parameters; |
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
[user] | |
email = [email protected] | |
name = That Guy | |
[push] | |
default = matching | |
[alias] | |
tree = log --graph --decorate --pretty=oneline --abbrev-commit | |
[hub] | |
protocol = https | |
[core] |
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
DECLARE @temp_error_log TABLE | |
( | |
date datetime, | |
process varchar(50) null, | |
text varchar(MAX) null | |
) | |
INSERT INTO @temp_error_log | |
EXEC sp_readerrorlog 0, 1, 'Login' |
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
SELECT sp.name AS login_name | |
FROM sys.server_principals sp | |
JOIN sys.database_principals dp ON (sp.sid = dp.sid) | |
WHERE dp.name = 'Joe' |
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
DECLARE @temp_error_log TABLE | |
( | |
date datetime, | |
process varchar(50) null, | |
text varchar(MAX) null | |
) | |
INSERT INTO @temp_error_log | |
EXEC sp_readerrorlog 0, 1--, 'Login failed' |
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
USE [AdventureWorks] | |
GO | |
ALTER USER [Joe] WITH LOGIN = [Joe] | |
GO |
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
DECLARE @Table varchar(255) = 'TableName' | |
DECLARE @Test char(1) = 'N' | |
DECLARE @FillFactorOverride varchar(3) = NULL | |
-- SET @Test = 'Y' to only output computed fill factor values. No database modifications will occur. | |
-- Set @FillFactorOverride to value other than NULL to override computed fill factor value | |
-- Example: @FillFactorOverride = '90' | |
-- ================================= | |
DECLARE @CursorTable varchar(255) | |
DECLARE @MyIndex varchar(255) | |
DECLARE @MyFillFactor varchar(3) |
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
-- http://lassesen.com/msdn/Optimizing_Fill_Factors_for_SQLServer.pdf | |
SELECT | |
'[' + s.name + '].[' + t.name + ']' AS TableName, | |
'[' + i.name + ']' AS IndexName, | |
SUM(c.Max_length) AS [KeySize], | |
CASE | |
WHEN SUM(c.Max_length) <= 900 AND | |
SUM(c.Max_length) > 848 THEN '97' | |
WHEN SUM(c.Max_length) <= 848 AND | |
SUM(c.Max_length) > 403 THEN '96' |
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
SELECT $displayName, $cn FROM ROOTDSE | |
WHERE $objectClass='user' AND $objectCategory='Person' | |
AND $sAMAccountName='x0000000' --AND $cn=''; |
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
-- server 'sysadmin' | |
SELECT name as 'sysadmin',type_desc,is_disabled | |
FROM master.sys.server_principals | |
WHERE IS_SRVROLEMEMBER ('sysadmin',name) = 1 | |
ORDER BY name | |
-- database owner | |
select suser_sname(owner_sid) as 'owner' | |
from sys.databases | |
where name = DB_NAME() |