Monday, December 12, 2016

Power Shell - Get UNC Path Directories

http://stackoverflow.com/questions/23574653/running-get-childitem-on-unc-path-works-in-powershell-but-not-in-powershell-run cd env: $foo = @{Name = "Foo"} $foo.Path = "\\serverPath\someDir\" $bar = @{Name = "Bar"} $bar.Path = "\\serverPath\someDir\" cd c: #THIS IS THE CRITICAL LINE @( $foo, $bar ) | ForEach-Object { $item = Get-ChildItem $_.Path # Do things with item Write-Host $item }

Wednesday, July 20, 2016

Monday, May 16, 2016

SQL Server Last Restore Time

-- Last Restore time WITH LastRestores AS ( SELECT DatabaseName = [d].[name] , [d].[create_date] , [d].[compatibility_level] , [d].[collation_name] , r.*, RowNum = ROW_NUMBER() OVER (PARTITION BY d.Name ORDER BY r.[restore_date] DESC) FROM master.sys.databases d LEFT OUTER JOIN msdb.dbo.[restorehistory] r ON r.[destination_database_name] = d.Name ) SELECT * FROM [LastRestores] WHERE [RowNum] = 1

Tuesday, March 15, 2016

ASPState DB

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ aspnet_regsql.exe -ssadd -sstype p -S server\instance -U sa -P somePass

Wednesday, January 6, 2016

Entity Framework (EF) 6 (or at least 6.13) Error - Missing Primary Keys

In the past EF would blow up when trying to make an *.edmx file on a table with no PK. As of EF 6 (or at least 6.13) it allows them but the result set returned when performing a join on a table will this version can/will be incorrect.

A deadly, but silent, error.

SQL Server Finding the Object Alter Date

select TOP 1 * from sys.procedures order by create_date desc 
select TOP 1 * from sys.tables  order by create_date desc 
select TOP 1 * from sys.views  order by create_date desc 

/*

CREATE PROC jkAlterProcTest 
AS 
SELECT 1 

CREATE TABLE jkAlterTableTest (a int) 

CREATE VIEW jkAlterViewTest 
AS 
SELECT a
FROM jkAlterTableTest 

ALTER PROC jkAlterProcTest 
AS 
SELECT 2

ALTER TABLE jkAlterTableTest ADD b int

ALTER VIEW jkAlterViewTest 
AS 
SELECT a, b 
FROM jkAlterTableTest 

*/