Skip to content

Instantly share code, notes, and snippets.

View othtim's full-sized avatar

Tim Scott othtim

  • Edmonton, Alberta, Canada
View GitHub Profile
@othtim
othtim / LSSDreport.sql
Created March 31, 2014 23:14
LSSD Daily Attendance Report
select
--s.clastname as 'lastname',
--s.cfirstname as 'firstname',
s.clastname + ', ' + s.cFirstName + ' (' + ltrim(rtrim(cast(s.istudentid as CHAR))) + ')' as [combinedname],
dbo.getgradesname(s.igradesid) as [grade],
h.cName as [homeroom],
l.cphone as [phone],
--a.iClassID as [class],
--a.ddate as [date],
( select COUNT(*) from Attendance att
@othtim
othtim / fixCourseClassGovLWCA.sql
Created March 31, 2014 23:15
Various fixes for course/class tables - LWCA
------------------------------------------------------------------------------------
--first term
update Class
set iLV_SessionID = 258
where iclassid in
(select iclassid from Class
@othtim
othtim / contact_reimport.sql
Last active August 29, 2015 13:57
Trinity / RENWEB conversion
drop table #contactrelation
drop table #contact
drop table #location
declare @ischoolid int
set @ischoolid = 1
@othtim
othtim / trailingBlankChecker.sql
Last active August 29, 2015 13:57
Check the database for fields with trailing blanks
drop table #temptable
select sObj.name as cTable, sCol.name as cColumn
into #temptable
from sys.tables sTable
inner join sys.columns sCol
on sCol.object_id = sTable.object_id
inner join sys.objects sObj
on sCol.object_id = sObj.object_id
inner join sys.types sType
@othtim
othtim / sino_conversion.sql
Created March 31, 2014 23:28
conversion scripts for Sino
begin transaction
delete from contact
--cstreet is too small
alter table location alter column cstreet varchar(70)
@othtim
othtim / bestofRandomizer.sql
Created March 31, 2014 23:30
"Best Of" request randomizer
/*
Trying to randomize the records in dbo.BestOfRequestDetail, but preserve them in sets of 10 by iBestOfRequestID.
*/
--clean up overall
if object_id('tempdb..#newresults') is not null
drop table #newresults;
if object_id('tempdb..#finalresults') is not null
drop table #finalresults;
@othtim
othtim / useagestats.sql
Last active August 29, 2015 13:58
Useage stats.sql
create table #SIRSusers (iCount int, cName varchar(100))
create table #TLXEusers (iCount int, cName varchar(100))
create table #HLSusers (iCount int, cName varchar(100))
create table #HLCusers (iCount int, cName varchar(100))
create table #totals (iCount int, cName varchar(100))
--HLS users
@othtim
othtim / ipcheck.sql
Created April 2, 2014 19:33
analyze IIS log errors by ip address
----select * from a
------total requests by IP
----select f9, count(*) from a
----group by f9
----order by 2 desc
@othtim
othtim / gist:345b0bc1e4a3c64dc8020c17d6658724
Last active April 28, 2017 21:12
SEP.cloud Logon script installer
try {
# check if SEP.cloud installed
$sym = Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where {$_.DisplayName -eq "Symantec Endpoint Protection.cloud"}
# if SEP.cloud is not installed
if(! $sym){
## first elevate to admin. Benjamin Armstrong
# Get the ID and security principal of the current user account
while (<>) {
$_ =~ s/\[\s+\d\]//g;
$_ =~ s/\s+/,/g ;
$_ =~ s/^,|,$//g;
print split(/\n/,$_);
print "\n";
}