This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<link rel="stylesheet" href="http://cmx.io/v/0.1/cmx.css"/> | |
<script src="http://cmx.io/v/0.1/cmx.js"></script> | |
<script type="text/javascript"> | |
<!-- | |
var frame2 = true; | |
var vis = {}; |
This file contains 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 Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains 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 @JulianDate integer = 114026; | |
select DATEADD(day,@JulianDate%1000-1,CAST(cast(@JulianDate/1000 + 1900 as varchar(4)) + '-01-01' as date)) ActualDate | |
--take the result calculated above into a variable | |
declare @ActualDate date --could use datetime if desired | |
set @ActualDate = DATEADD(day,@JulianDate%1000-1,CAST(cast(@JulianDate/1000 + 1900 as varchar(4)) + '-01-01' as date)) | |
--format it however you fancy (see http://www.w3schools.com/sql/func_convert.asp) | |
select CONVERT(nvarchar(24), @ActualDate, 113) |
This file contains 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 julianDateCol | |
, case | |
when nvl( julianDateCol ,0)=0 | |
then 'no date' | |
else to_char | |
( | |
to_date | |
( | |
1000 * | |
( |
This file contains 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 | |
1000 * (TO_NUMBER(TO_CHAR(SYSDATE,'YYYY')) - 1900) | |
+ ( | |
TO_DATE(TO_CHAR(SYSDATE, 'DD/MM/YYYY'), 'DD/MM/YYYY') | |
- TO_DATE('01/01/' || TO_CHAR(SYSDATE,'YYYY'),'DD/MM/YYYY') | |
) | |
+ 1 | |
Todays_Date_As_Julian | |
from dual; |
This file contains 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 1000 * (DATEPART(YEAR, GETUTCDATE())-1900) | |
+ DATEDIFF(day,DATEADD(year, datepart(YEAR,getutcdate())-1900, 0),getutcdate()) |
This file contains 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
--Still a work in progress to make it fully SQL, but here’s a way to grab all of the XMLs and names from production – so it’s only the pasting side left to automate. | |
use [eam-rep] --eamProduction\SQL05 | |
go | |
;with pathBuilderCte as --based on info from: http://cognospaul.com/2012/03/04/8-2-export-all-report-xmls-to-file-system/ | |
( | |
select o.CMID id, cast('root' as nvarchar(max)) namePath | |
from cmobjnames n |
This file contains 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
public static class ObjectExtensions | |
{ | |
public static string ToStringIfNotNull(this object o) | |
{ | |
return o == null ? null : o.ToString(); | |
} | |
} |
This file contains 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 dbschemas.[name] as 'Schema', | |
dbtables.[name] as 'Table', | |
dbindexes.[name] as 'Index', | |
indexstats.avg_fragmentation_in_percent, | |
indexstats.page_count | |
FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL, NULL, NULL) AS indexstats | |
INNER JOIN sys.tables dbtables on dbtables.[object_id] = indexstats.[object_id] | |
INNER JOIN sys.schemas dbschemas on dbtables.[schema_id] = dbschemas.[schema_id] | |
INNER JOIN sys.indexes AS dbindexes ON dbindexes.[object_id] = indexstats.[object_id] | |
AND indexstats.index_id = dbindexes.index_id |
This file contains 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 EnergyLive | |
go | |
SELECT REQ.SESSION_ID, | |
RTRIM(convert(varchar(128),REQ.context_info)) AS BATCH_INFO, | |
SQL = SQL.text, | |
QUERYPLAN.query_plan AS EXEC_PLAN, | |
CPU_TIME, | |
TOTAL_ELAPSED_TIME, | |
READS, |
OlderNewer