LessThanDot Site Logo

LessThanDot

A decade of helpful technical content

This is an archive of the posts published to LessThanDot from 2008 to 2018, over a decade of useful content. While we're no longer adding new content, we still receive a lot of visitors and wanted to make sure the content didn't disappear forever.

Presenting Yourself – Visually and Respectfully

The Successful Consulting Series is a set of articles that are being written to both, help decisions on joining the consulting field and also, help existing consultants in their professional development initiatives. Please visit, “Successful Consulting Series” for a full listing of each part in this series. Presenting yourself as a consultant is the first stage in being successful in terms of clients and your team. Most times, the client will be the critical variable in the equation to your overall success rate as a consultant. Let’s face it, if the client is not happy with how you’ve presented yourself and skills, both you and possibly the consulting company you work for are at a complete loss. However, your team is just as critical to the success rate.

Read More...

Getting remote Mount Point information with PowerShell

In a previous post I showed how to get remote disk information with PowerShell. The script works nice until you execute it on a server with Mount Points. When executing the following script on a server with Mount Points: Get-WmiObject win32_logicaldisk -computer <computername> | select-object DeviceID, VolumeName, @{Name="Size";Expression={$_.Size/1GB}},@{Name="FreeSpace";Expression={$_.FreeSpace/1GB}}, @{Name="PCTFreeSpace";Expression={ $_.FreeSpace/$_.Size*100}}|Sort-Object -descending PCTfreespace|format-table I get the following result: Knowing the sizes of my databases, I knew the numbers were wrong. So I opened a RDP session to the server and found this picture in Disk Management:

Read More...

Java Training Day 3

Today was day three of our Java training, we did mostly OOP stuff today. I also noticed that whenever you do a week of training by the team that Wednesday PM comes along, you are pretty much mush. We covered Object Oriented design, why you would use it, we covered Encapsulation, Inheritance and Polymorphism. You encapsulate functionality in classes, you hide the implementation so that the classes can be treated as black boxes, the person using your classes does not need to know how stuff is implemented, all the person needs to know is what the class does. Inheritance enables you to basically make a copy of a class.

Read More...

Successful Consulting Series

Sometimes, as a speaker, the best sessions I’ve presented or co-presented are the ones that are non-technical in nature. One I’ve been fortunate to co-present with Hope Foley (B | @Hope_Foley) is “Consulting – The Good, The Bad, The Ugly". I’ve received a ton of positive feedback from that session, as well as many questions expanding on the topics. Being a successful consultant involves much more than being a successful DBA or Developer. There are many areas that are critical aside from the high level of skills that are needed in the technical areas you are selling your services for. Presentation, gaining trust, relationships, managing your time, efficiency and overall productivity, all become a foundation. Without them and many more, a consulting career can be met with stress and overall poor performance and lost objectives/goals.

Read More...

Utilizing SQL Server Reports from SSMS

I was working with someone today that had little knowledge of navigating SSMS and other common tools for SQL Server. At times, we really need to step back and remember that not everyone touches a tool like SSMS almost daily. That is in part a consulting concept and one that should be taken seriously when it comes to not letting your work with others frustrate you. Remember, if something isn’t going right in a situation, even as minor as retrieving SQL Server configuration information, it typically means you need to be better at how you are explaining it or take a better path to obtaining the information.

Read More...

Book Review: On Writing Well

Secret: when I was in high school, I was going to grow up to be a high school English teacher and writer. I read voraciously. I wrote endlessly – journals, short stories, poems, and essays. I haven’t become a teacher yet, but I’ve kept my love of writing alive. I’ve been blogging – personally and professionally – for years and even co-authored a book this year! To me, writing is an art form. I can only get better at it, but it will take time, and practice. I was discussing writing with Jeremiah (blog | twitter) one day, and he recommended I read William Zinsser’s On Writing Well The Classic Guide to Writing Nonfiction for inspiration.

Read More...

Your queue is not threadsafe and sometimes that can give unwanted sideeffects

Introduction For one of my projects I needed to show the 30 last messages to the user. I was not interested in keeping these messages. So I decided to use a queue. The messages come from different sources and different threads. And the different threads bit is important. The queue Here is what can happen if you use the not threadsafe queue. Let’s take this little example. Imports System.Threading Module Module1 Private _queue As Queue(Of String) Private _count As Integer Sub Main() Console.WriteLine("Not concurrent threads") _count = 0 Dim t As New Thread(New ParameterizedThreadStart(Sub() Addmessages(Sub(x) AddMessage(x)))) Dim t2 As New Thread(New ParameterizedThreadStart(Sub() Addmessages(Sub(x) AddMessage(x)))) Dim t3 As New Thread(New ParameterizedThreadStart(Sub() Addmessages(Sub(x) AddMessage(x)))) Dim t4 As New Thread(New ParameterizedThreadStart(Sub() Addmessages(Sub(x) AddMessage(x)))) t.Start() t2.Start() t3.Start() t4.Start() Do While _count &lt; 4 Loop _count = 1 For Each q In _queue.Reverse.ToList Console.WriteLine(_count & ". " & q) _count += 1 Next Console.ReadLine() End Sub Public Sub Addmessages(ByVal action As Action(Of String)) For x = 1 To 1000000 action.Invoke("test") Next _count += 1 End Sub Public Sub AddMessage(message As String) If _Queue Is Nothing Then _queue = New Queue(Of String)(1000000) End If If Not String.IsNullOrEmpty(message) Then _Queue.Enqueue(message) End If Dim result As String If _queue.Count &gt; 10 Then _queue.Dequeue() End If End Sub End Module``` That is 4 threads that add 1000000 messages to the queue at an alarming rate. And I only want to keep the last 10 messages in my queue. The result. > 128683. test > 128684. test > 128685. test > 128686. test > 128687. test > 128688. test > 128689. test > 128690. > 128691. test > 128692. test > 128693. test > 128694. test > 128695. test > 128696. test > 128697. test > 128698. test > 128699. test > 128700. test > 128701. test > 128702. test > 128703. test > 128704. test Those are only the last ones. There are 128704 elements in our queue and some are empty. Not sure how I get the empty ones but I guess it must be somewhere between an enqueue and a dequeue. Anyway the results are not what we desire. And of course now I could start adding blocks here and there to make sure the enqueue and dequeue are atomic operations and what not but Since .Net 4.0 there are Concurent collections and they are threadsafe by design. Lucky us. ## The concurrent queue We can simply change our code to this. ```vbnet Imports System.Collections.Concurrent Imports System.Threading Module Module1 Private _concurrentQueue As ConcurrentQueue(Of String) Private _count As Integer Sub Main() Console.WriteLine("concurrent threads") _count = 0 Dim t5 As New Thread(New ParameterizedThreadStart(Sub() Addmessages(Sub(x) AddMessageConcurrently(x)))) Dim t6 As New Thread(New ParameterizedThreadStart(Sub() Addmessages(Sub(x) AddMessageConcurrently(x)))) Dim t7 As New Thread(New ParameterizedThreadStart(Sub() Addmessages(Sub(x) AddMessageConcurrently(x)))) Dim t8 As New Thread(New ParameterizedThreadStart(Sub() Addmessages(Sub(x) AddMessageConcurrently(x)))) t5.Start() t6.Start() t7.Start() t8.Start() Do While _count &lt; 4 Loop _count = 1 For Each q In _concurrentQueue.Reverse.ToList Console.WriteLine(_count & ". " & q) _count += 1 Next Console.ReadLine() End Sub Public Sub Addmessages(ByVal action As Action(Of String)) For x = 1 To 1000000 action.Invoke("test") Next _count += 1 End Sub Public Sub AddMessageConcurrently(message As String) If _concurrentQueue Is Nothing Then _concurrentQueue = New ConcurrentQueue(Of String)() End If If Not String.IsNullOrEmpty(message) Then _concurrentQueue.Enqueue(message) End If Dim result As String If _concurrentQueue.Count &gt; 10 Then _concurrentQueue.TryDequeue(result) End If End Sub End Module And now the result is.

Read More...

Java Training Day 2

This is day two of the Java training that our group is taking. Today nothing really complicated was covered, nobody looked like a zombie yet, I am sure by Friday, that will be different. Here is a quick rundown of what was covered Control statements if The if has to have parentheses and it has to be a boolean expressions if (boolean-expression) {statement}; We also covered the while and do while loop followed by the for loop

Read More...

Book Review: Microsoft SQL Server 2012 T-SQL Fundamentals

With a basis as a system engineer, I became a DBA. And DBA’s don’t often write real DML queries. I can read a query, understand what it’s doing but when I need to read one I need BOL the help me out. Taking the 070-457 Transition Your MCTS on SQL Server to MCSA: SQL Server 2012,Part 1 exam showed me I’m strong in database administration but there was room for improvement for my query skills. That’s why I bought Microsoft SQL Server 2012 T-SQL Fundamentals by Itzik Ben-Gan (blog | twitter).

Read More...

What's the deal with Excel & SSIS?

When it comes to importing data from an Excel sheet with SSIS, Excel has quite a reputation. And not a terribly good one. Well deserved, to be honest, because numerous issues can rise when dealing with this piece of software. This blog post will deal with the issue I encounter the most on forums, which is the issue of the mixed data types in one column, also known as "Why is some of my data read as NULL?".

Read More...