Tuesday, October 9, 2012

Microsoft Test Manager 2012 Setup

There is not much difference between 2010 and 20012 MTM. The subtle differences are covered in any number of blog posts. However I often forget what order you need to create settings when installing form scratch, hence this post.

Close visual studio
Install visual studio test edition or ultimate.
Reboot not once, but twice.
If you have not already done so, install TFS power tools to modify areas and iterations.
open test manager
create all your test plans for each project names should be meaningful from iteration to iteration if the test plans is reusable
write your test plans to be reusable as much as possible.
create a lab environment
create roles based on the environment
...stopping here as TMT 2012 does not allow environment configuration against TFS 2010.

Wednesday, September 26, 2012

CTO Interview Question Set



Have candidate describe his current role and skills
Describe our position.

Ask candidate these questions:
How do you communicate financial justifications for staffing, hardware, and software?
How do you amortize time spent developing software?
Where is the line of responsibility drawn between technical and business planning?
How do you stay current with technology innovations?
How are the acronyms API and SSO relevant to a web architecture?
What excites you about technology ?
What means do you use to measure the effectiveness of your technology department? How do you communicate that to non-technical cohorts in the c-suite or on a board of directors?
What role does a CTO play in ensuring retention of key engineering assets?
What do you communicate in a technology roadmap and who is the audience?
What is a product roadmap and how does it vary from a technology roadmap? Who is the author of each?

Monday, August 13, 2012

The Following Path Contains More than 259 Characters

There are a number of articles telling you how to reduce the path length through creative mapping (look into the \\?\ syntax). This is an issue when assemblies are gened in a long path structure.

More people need to talk about the creation of .datasource files. These suckers have a default naming convention that concatenates namespace childnamespace sub-childnamespace(n) name.datasource. This is a different issue pointed out by Praphulla Parab These are removable and avoidable.


ISSUE
These get created whenever you add a service reference to a project. These are generated automatically during the generation of the proxy class in the Reference.cs file.

This can easily make the file name lengthier than allowed. If we prefix the path to the file in the Source Control repository hierarchy, the entire path length can easily exceed the TFS 259 character limit. So far the .datasource file does not seem to be a required dependency to build the project.

RESOLUTION
Delete all datasource files and reject .datasource files in your check-in policy.  There is a trick to delete files you have not downloaded locally. Us the tf.exe tool. You must then check in the deletion of the file. Final step is to make a forbidden patterns check in policy using the regex \.datasource$ This is at the scope of the Team Project project definition.Note this is on the Team Project, so it effects everyone.

EG
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE> tf delete $<long path>/file.datasource

Thursday, August 2, 2012

Powershell Deploy Template - Set app_offline.html

#create variables for file names used in move
$hideFile = "app_offline.off.htm"
$liveFile = "app_offline.htm"

#create an array of directories you want to swap files in
$path = @(
"C:\InetPub\Site1"
,"C:\InetPub\Site2"
,"C:\InetPub\Site3"
)

#counters for while loop based on number of directories
#NOTE: Count enumerates from 1. array position enumerates from 0
$maxCnt = $path.Count
$currCnt = 0

#create a log
$logFile = "\temp.txt"
Set-Variable -name log -value $env:userprofile$logFile
if (Test-Path $log) {rm $log}
New-Item $log -type file

#set-variable was used to construct the path due to errors I was getting calling the path and file variables on the fly
#NOTE: Count enumerates from 1. array position enumerates from 0
while ($currCnt -lt $maxCnt)

{
Set-Variable -name currPath -value $path[$currCnt.ToString()]
;  Set-Variable -name hidePath -value $currPath$hideFile
;  Set-Variable -name livePath -value $currPath$liveFile
;  Set-Variable -name currTime -value (Get-Date)
; Move-Item $hidePath  $livePath >> $log
; echo "$currTime moved $hidePath to $livePath"  >> $log
; $currCnt = $currCnt +1
}

Thursday, July 5, 2012

T-SQL - Common Table Expressions are as Performant as Inline Tables

Common table expressions are as performant as inline table queries. This was something I have to prove to myself. I ran the same query written both as an inline table and CTE several times. for 629,000 rows I had the same execution time (13 seconds) every single time with both queries. The query plan was identical, down to the the estimate total subtree cost for each operation. The advantage for a CTE comes out in iterative processing and a cleaner style (in my opinion).


EXAMPLE 1
SELECTMIN(a.Date1) AS Date1,a.PersonIDFROM(SELECT DISTINCTDate1,PersonIDFROMTable2UNIONSELECT DISTINCTDate1,OtherPersonID AS PersonIDFROMTable1

) AS aLEFT JOIN Table3 (nolock) AS bON (ISNULL(a.PersonID,'?') = b.SomeKey SomeKey)
WHERE b.SomeKey IS NULL
GROUP a

EXAMPLE 2
WITHa AS(SELECT DISTINCTDate1,PersonIDFROMTable2UNION SELECT DISTINCT Date1,OtherPersonID AS PersonID FROMTable1

) SELECT MIN(a.Date1) AS Date1,a.PersonID

FROM a LEFT JOIN Table3 (nolock) AS b ON (ISNULL(a.PersonID,'?') = b.SomeKey )WHERE b.SomeKey IS NULL
GROUP a BY .PersonID BY .PersonID

Friday, June 22, 2012

A Little More Dynamic SQL - Condtitional WHERE

/*
TEST: Find Data
*/
--create a table variable to store the source/target mappings
DECLARE
@SourceTarget Table(ID INT Identity (1,1),TargetServer nVarchar(300),TargetDB nVarchar(300),TargetSchema nVarchar(300),TargetTable nVarchar(300),SourceServer Nvarchar (300),SourceDB nVarchar(300),SourceSchema nVarchar(300),SourceTable nVarchar(300),SourceKeyCols nVarchar(300),TrgKeyCols nVarchar(300))
--populate the table with the ETL table mappings for this project
INSERT INTO @SourceTarget(TargetServer ,TargetDB ,TargetSchema ,TargetTable,SourceServer ,SourceDB ,SourceSchema ,SourceTable
)
VALUES
(
(
'SERVER','DATABASE','dbo','Table1','Server2','databse2','schema','Table1.1'),'SERVER','DATABASE','dbo','Table2','Server2','databse2','schema','Table2.1')
--Declare the variables used in the test
DECLARE
@StartCnt
INT = 1,@MaxCnt INT = (SELECT COUNT (1) FROM @SourceTarget),@SourceServer nVarchar(100),@SourceDB nVarchar(100),@SourceSchema nVarchar(100),@SourceTable nVarchar(100),@TargetServer nVarchar(100),@TargetDB nVarchar(100),@TargetSchema
@TargetTable
nVarchar(100), nVarchar(100),@Today nVarchar(8),
--used to dynamically determine the column names for the row meta data
@Where nVarchar(MAX),
--use for creating the dynamic SQL
@sql
nVarchar(MAX)
WHILE
@StartCnt <= @MaxCnt
BEGIN
--set the values for each four part table name we want to testSET @SourceServer = (SELECT SourceServer FROM @SourceTarget WHERE ID = @StartCnt)SET @SourceDB = (SELECT SourceDB FROM @SourceTarget WHERE ID = @StartCnt)SET @SourceSchema = (SELECT SourceSchema FROM @SourceTarget WHERE ID = @StartCnt)SET @SourceTable = (SELECT SourceTable FROM @SourceTarget WHERE ID = @StartCnt)SET @TargetServer = (SELECT TargetServer FROM @SourceTarget WHERE ID = @StartCnt)SET @TargetDB = (SELECT TargetDB FROM @SourceTarget WHERE ID = @StartCnt)SET @TargetSchema = (SELECT TargetSchema FROM @SourceTarget WHERE ID = @StartCnt)SET @TargetTable = (SELECT TargetTable FROM @SourceTarget WHERE ID = @StartCnt)SET @Today = (SELECT CONVERT(CHAR(8), GetDate(), 112))IF @SourceTable IN ('table1')
BEGIN SET @Where = 'WHERE Created_Date > '''
SET @Where = @Where + @TodaySET @Where = @Where + ''' '
and DATEPART(mm, Created_Date) = DATEPART(mm, Updated_Date)
and DATEPART(yy, Created_Date) = DATEPART(YY, Updated_Date)'
SET @Where = @Where + 'and DATEPART(dd, Created_Date) = DATEPART(dd, Updated_Date)

ELSE
IF
END @SourceTable IN ('tabel2')
BEGINSET @Where = 'WHERE created_date > '''
SET @Where = @Where + @Today SET @Where = @Where + ''' '
and DATEPART(mm, Created_date) = DATEPART(mm, Updated_date)
and DATEPART(yy, Created_date) = DATEPART(YY, Updated_date)'
SET @Where = @Where + 'and DATEPART(dd, Created_date) = DATEPART(dd, Updated_date)

ELSE
END
BEGINSET @Where = 'WHERE createdDate > '''
SET @Where = @Where + @TodaySET @Where = @Where + ''' '
DATEPART(dd, CreatedDttm) = DATEPART(dd, UpdatedDttm)
AND DATEPART(mm, CreatedDttm) = DATEPART(mm, UpdatedDttm)
AND DATEPART(yy, CreatedDttm) = DATEPART(YY, UpdatedDttm)
)
OR (
DATEPART(dd, CreatedDttm) = DATEPART(dd, DeletedDttm)
AND DATEPART(mm, CreatedDttm) = DATEPART(mm, DeletedDttm)
AND DATEPART(yy, CreatedDttm) = DATEPART(YY, DeletedDttm)
)
OR (
DATEPART(dd, UpdatedDttm) = DATEPART(dd, DeletedDttm)
AND DATEPART(mm, UpdatedDttm) = DATEPART(mm, DeletedDttm)
AND DATEPART(yy, UpdatedDttm) = DATEPART(YY, DeletedDttm)
)
'
SET @Where = @Where + 'AND (
END
SET @sql = ' + @SourceServer + '.' + @SourceDB + '.' + @SourceSchema + '.' + @SourceTable+ space(1) + 'WITH (NOLOCK) '


'
+ space(1) + @Where + '


PRINT
EXEC sp_executesql @sql OUTPUT @Today PRINT @WhereSET @StartCnt = @StartCnt +1;END

SELECT * FROM '





 
 

 

Wednesday, June 20, 2012

DB Stuff: Beyond sp_who

--This is a query designed to return all processes in all dbs on one server.



--declare a table to hold the results. allows for filtering and sorting

 DECLARE @TempTbl TABLE (DBName nVarchar(300), session_id INT, login_time nVarchar(300), host_name nVarchar(300), program_name nVarchar(300), host_process_id nVarchar(300), client_version nVarchar(300), client_interface_name nVarchar(300), security_id nVarchar(300), login_name nVarchar(300), nt_domain nVarchar(300), nt_user_name nVarchar(300), status nVarchar(300), context_info nVarchar(300), cpu_time nVarchar(300), memory_usage nVarchar(300), total_scheduled_time nVarchar(300), total_elapsed_time nVarchar(300), endpoint_id nVarchar(300), last_request_start_time nVarchar(300), last_request_end_time nVarchar(300), reads nVarchar(300), writes nVarchar(300), logical_reads nVarchar(300), is_user_process nVarchar(300), text_size nVarchar(300), language nVarchar(300), date_format nVarchar(300), date_first nVarchar(300), quoted_identifier nVarchar(300), arithabort nVarchar(300), ansi_null_dflt_on nVarchar(300), ansi_defaults nVarchar(300), ansi_warnings nVarchar(300), ansi_padding nVarchar(300), ansi_nulls nVarchar(300), concat_null_yields_null nVarchar(300), transaction_isolation_level nVarchar(300), lock_timeout nVarchar(300), deadlock_priority nVarchar(300), row_count nVarchar(300), prev_error nVarchar(300), original_security_id nVarchar(300), original_login_name nVarchar(300), last_successful_logon nVarchar(300), last_unsuccessful_logon nVarchar(300), unsuccessful_logons nVarchar(300), group_id INT)

INSERT INTO @TempTbl
SELECT DB_NAME(dbid),s.*
FROM sys.dm_exec_sessions s
LEFT OUTER JOIN sys.sysprocesses p
ON S.session_id = p.spid
WHERE dbid > 0SELECT *
FROM @TempTbl
WHERE
      login_name
NOT IN ('sa', '<domain>\<server>', '<db_user>')
      AND DBName NOT IN ('master')
ORDER BY DBName, login_name

--This query is sp_who in a filterable fashion

DECLARE @WhoTbl TABLE
(SPID INT,[Status] nVarchar(300),
[Login] nVarchar(300),
HostName nVarchar(50),BlkBy varchar(300),DBName nVarchar(300),Command nVarchar(3000),CPUTime INT,DiskIO INT,LastBatch varchar(300),ProgramName nVarchar(300),SPID2 INT,REQUESTID INT)

INSERT INTO @WhoTbl
EXEC sp_who2

SELECT * FROM @WhoTbl
WHERE
DBName
NOT IN ('master', 'msdb')

ORDER BY DBName