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
/* thanks to http://stackoverflow.com/questions/18390574/how-to-delete-duplicate-rows-in-sql-server */ | |
/* partition on the columns that make the row unique */ | |
with dupes as ( | |
select *, rn = ROW_NUMBER() OVER (PARTITION BY col1, col2 ORDER BY col1) | |
from sources | |
) | |
delete from dupes | |
where rn > 1 |
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
// add some functions (or override some functions) | |
// e.g. $(selector).autocomplete("doMore", data); | |
$.widget("ui.autocomplete", $.ui.autocomplete, { | |
doMore: function (data) { | |
// this = autocomplete object | |
// this.element = auto complete input element | |
}, |
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 @sourcebackupfolder varchar(255), @targetbackupfolder varchar(255), @targetdatafolder varchar(255), @targetlogfilder varchar(255) | |
select @sourcebackupfolder = 'c:\moving\', @targetbackupfolder='d:\moving\', @targetdatafolder='c:\sql\data\', @targetlogfilder='c:\sql\logs\'; | |
select 'BACKUP DATABASE [' + name + '] TO DISK = ''' + @sourcebackupfolder + name | |
+ '.bak'' WITH INIT , NOUNLOAD , NAME = ''' + name + ''', NOSKIP , STATS = 100, NOFORMAT' | |
from sys.databases | |
where name not in ('master','msdb','model','tempdb'); |
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 | |
'IF NOT EXISTS (SELECT * FROM master.sys.sql_logins WHERE [name] = ''' + [name] + ''') | |
CREATE LOGIN [' + [name] + '] | |
WITH PASSWORD=' + master.sys.fn_varbintohexstr(password_hash) + ' HASHED, | |
SID = ' + master.sys.fn_varbintohexstr([sid]) + ', | |
DEFAULT_LANGUAGE=[us_english], | |
CHECK_EXPIRATION=' + CASE WHEN is_expiration_checked = 1 THEN 'ON' ELSE 'OFF' END + ', CHECK_POLICY=OFF | |
GO | |
IF EXISTS (SELECT * FROM master.sys.sql_logins WHERE [name] = ''' + [name] + ''') | |
ALTER LOGIN [' + [name] + '] |
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
# delete old SharePoint 2010 event receivers to eliminate duplicate workflow actions | |
function examineWeb($web) { | |
$spLists = $web.Lists; | |
for ($listnum=0; $listnum -lt $spLists.Count; $listnum+=1) | |
{ | |
$($web.Title + " - " + $spList.Title) |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.IO; | |
// just some rough playing around converting an object to RDF Turtle. | |
class ObjectToTurtle | |
{ |
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 | |
ex.UserName, ex.Format, | |
cat.Path, | |
cat.Name, ex.Parameters, | |
CONVERT(nvarchar(10), ex.TimeStart, 101) AS rundate, | |
ex.TimeStart, ex.TimeEnd, ex.TimeDataRetrieval, ex.TimeProcessing, ex.TimeRendering, ex.Status, | |
ex.ByteCount, ex.[RowCount] | |
FROM ReportServer..ExecutionLog AS ex INNER JOIN | |
ReportServer..Catalog AS cat ON ex.ReportID = cat.ItemID | |
ORDER BY ex.TimeStart 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
-- in this case we're giving the cert permission to alter the schema | |
-- (maybe explicitly disably identify and insert something into an identity column) | |
-- set up cert with permission to alter schema... | |
CREATE MASTER KEY ENCRYPTION BY password = '**opensesame**'; | |
CREATE CERTIFICATE SchemaCert WITH SUBJECT = 'Schema user Certificate' | |
CREATE USER SchemaCertUser FROM CERTIFICATE SchemaCert | |
GRANT ALTER ANY SCHEMA TO SchemaCertUser | |
-- run or rerun the following line whenever you alter procedure, |
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 | |
DB_NAME(DPS.DATABASE_ID) AS [DatabaseName] | |
,OBJECT_NAME(DPS.OBJECT_ID) AS TableName | |
,SI.NAME AS IndexName | |
,DPS.INDEX_TYPE_DESC AS IndexType | |
,DPS.AVG_FRAGMENTATION_IN_PERCENT AS AvgPageFragmentation | |
,DPS.PAGE_COUNT AS PageCounts | |
FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL , NULL, NULL) DPS --N'LIMITED') DPS | |
INNER JOIN sysindexes SI | |
ON DPS.OBJECT_ID = SI.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
select top 100 | |
qs.max_elapsed_time/1000000.00, | |
db.name db, | |
ob.name object, | |
substring(st.text,1,100) preview, | |
total_worker_time/execution_count AS [Avg CPU Time], | |
SUBSTRING(st.text, (qs.statement_start_offset/2)+1, | |
((CASE qs.statement_end_offset | |
WHEN -1 THEN DATALENGTH(st.text) | |
ELSE qs.statement_end_offset |