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 DateTimeHelper | |
{ | |
public static DateTimeOffset Combine(DateTimeOffset? originalDate, string timeString, int timeZoneOffsetInMinutes) | |
{ | |
if(originalDate.HasValue) | |
{ | |
return FromString(GetDateAsString(originalDate.Value.Date, timeString, timeZoneOffsetInMinutes)); | |
} | |
else | |
{ |
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
#assuming the date is 25-JAN-2018 at 01:30:52 | |
#the code below shouldPrint "AllPivots_20180125_0130" | |
from datetime import datetime | |
current = datetime.utcnow() | |
print(current) | |
year = str(current.year) | |
month = str(current.month).zfill(2) | |
day = str(current.day).zfill(2) | |
hours = str(current.hour).zfill(2) |
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 name | |
from [tst-IrrigationReporting].sys.tables | |
where name like 'YourTableName_2018%' | |
-- and is_ms_shipped = 0; | |
DECLARE @cmd varchar(4000) | |
DECLARE cmds CURSOR FOR | |
SELECT 'drop table [' + Table_Name + ']' | |
FROM INFORMATION_SCHEMA.TABLES | |
WHERE Table_Name LIKE 'YourTableName_2018%' |
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
-- https://blog.sqlauthority.com/2017/05/25/sql-server-simple-query-list-size-table-row-counts/ | |
USE [YourDBName] -- replace your dbname | |
GO | |
SELECT | |
s.Name AS SchemaName, | |
t.Name AS TableName, | |
p.rows AS RowCounts, | |
CAST(ROUND((SUM(a.used_pages) / 128.00), 2) AS NUMERIC(36, 2)) AS Used_MB, | |
CAST(ROUND((SUM(a.total_pages) - SUM(a.used_pages)) / 128.00, 2) AS NUMERIC(36, 2)) AS Unused_MB, | |
CAST(ROUND((SUM(a.total_pages) / 128.00), 2) AS NUMERIC(36, 2)) AS Total_MB |
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
sp_who2 | |
DECLARE @sqltext VARBINARY(128) | |
SELECT @sqltext = sql_handle | |
FROM sys.sysprocesses | |
WHERE spid = 62 | |
SELECT TEXT | |
FROM sys.dm_exec_sql_text(@sqltext) | |
GO |