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.

What does a SQL Server developer need to know?

I have been interviewing people for a SQL Server position for the past six weeks and all I can say that I am glad it is over. What a frustrating experience, people with over 10 years’ experience could not tell me the difference between UNION and UNION ALL, most of the people never heard of TRUNCATE. We finally got our guy and he starts tomorrow. So I would like to ask you the reader what a SQL Server developer should know when he falls into these levels.

Read More...

Latest article by SQL Server MVP Erland Sommarskog is a gem

SQL Server MVP Erland Sommarskog has posted his latest article yesterday and I highly recommend printing it out/transferring it to your ebook reader and reading it. Of course I think most of you are already familiar with Erland’s article The curse and blessings of dynamic SQL, this article I am sure will be linked in answers as much as the dynamic SQL one Remember all those question you get where a query is fast in SSMS but slow from ADO.NET? Yep that pesky ARITHABORT setting which causes problem…this is covered in this article.

Read More...

Professional Development Week, An introduction to this week on SQL University

Welcome to this semester’s Professional Development week at SQL University. This week long course will dive deep into professional development in order to better build ourselves for the careers we are already far into building. This week is being taught by Andy Leonard (Twitter | Blog) and Ted Krueger (Twitter | Blog). Andy is well known for bringing the community together and having the ability to mentor from the individual level to large groups of the community with developing skills to build their careers. This week will be a collection of both author’s experiences and suggestions that they have built in our own careers over this past decade. When the week comes to a close, students will take away notes that will assist them with an already well rounded career and start polishing their professional career and start developing it even further.

Read More...

Parsing the FullName field to individual components

This post expands on my previous post on the similar topic Parsing the Address field to its individual components I encourage the readers who are unfamiliar with the CROSS APPLY technique used in this blog to read this very interesting blog by Brad Schulz T-SQL Tuesday #017: APPLY: It Slices! It Dices! It Does It All! This time I will be solving a similar problem of parsing names to individual components. It is based on the following MSDN thread.

Read More...

Windows 7 SP1 RTM available for MSDN and TechNet customers

If you are a TechNet or MSDN subscriber then you can download Windows 7 Service Pack 1 or Window Server 2008 R2 Service Pack 1 today. Below is an image of what is available If you are a not a TechNet or MSDN subscriber, you have to wait until February 22nd to download yours. If you have been patching your Windows 7 machine then you already have most of what is in the service pack, the service pack is just a rollup of all the patches that have been issued since Windows 7 was released. It is still handy if you have a new machine since you don’t need to then download all the patches

Read More...

Trapping errors when working with linked servers

I have a bunch of linked servers to SQL Servers and also to Sybase ASE Servers ON AIX machines. There are some interesting things that can happen. For example if you type the name of the object or the linked server itself wrong, you can’t trap this….. or can you? Let’s take a look. Open up SSMS and connect to your local instance. Now create a linked server named TestLinkedServer which points to the local server. The code to do that is below.

Read More...

Changing a SQL Server Database Owner

Fact: every SQL Server database has an “owner”. You can check the owner of a database by running this query: SELECT NAME, SUSER_SNAME(owner_sid) FROM sys.databases WHERE NAME = 'DatabaseName' However, there may come a day when you run into this error: There was error outputting database level information for ServerName.DatabaseName. Property Owner is not available for Database ‘[DatabaseName]’. This property may not exist for this object, or may not be retrievable due to insufficient access rights.

Read More...

24 Hours of PASS, WIT Edition: Register! Learn! Listen to Me!

Last month, I asked a group of amazing women to submit sessions for the Spring 2011 24 Hours of PASS, focusing on Women In Technology (WIT). 24 HOP will take place on Tuesday, March 15 and Wednesday, March 16, 2011. The call for speakers came and went. I was stoked when I heard that 59 sessions were submitted. 59! That’s enough for two and a half days of training!

Read More...

Inverse Mapped Collections and NHibernate's Second-Level Cache

In order to simplify saving some entities, I recently changed some mappings in my application to use the inverse attribute. In less cryptic terms, this means that the collection item is responsible for maintaining the relationship to the collection owner. In contrast, when using a standard relationship the parent entity is responsible for managing the collection items. The reason for this is that it lets you save the collection items without going to the database (or second level cache) to get the collection’s owner.

Read More...

MailMessage and changing the name of an attachment

Whenever my application doesn’t close correctly (meaning it probably crashed) I get sent the log files at next startup via mail. In this mail I have the log files attached. Because the log files are locked at the time of sending I first take a copy of them like this, you can take a copy of a file while it is locked. For Each _Filename As String In _attachements _Filename = Environment.CurrentDirectory & "" & _Filename If System.IO.File.Exists(_Filename) Then If System.IO.File.Exists(_Filename & ".copy") Then System.IO.File.Delete(_Filename & ".copy") End If System.IO.File.Copy(_Filename, _Filename & ".copy") Dim _attachment As New System.Net.Mail.Attachment(_Filename & ".copy") _message.Attachments.Add(_attachment) _message.Body &= "&lt;p&gt;Attached file: " & _Filename & "&lt;/p&gt;" Else _message.Body &= "&lt;p&gt;File not attached: " & _Filename & " because file does not exists.&lt;/p&gt;" End If Next``` Of course this means that the filename in the mail will end in copy (which means it will not open in your favorite program when you double click it) or not be the same as the original or some other reason. This is not really a problem if you know how to change the name back to the original name which you can see in the following piece of code. ```vbnet For Each _Filename As String In _attachements _Filename = Environment.CurrentDirectory & "" & _Filename If System.IO.File.Exists(_Filename) Then If System.IO.File.Exists(_Filename & ".copy") Then System.IO.File.Delete(_Filename & ".copy") End If System.IO.File.Copy(_Filename, _Filename & ".copy") Dim _attachment As New System.Net.Mail.Attachment(_Filename & ".copy") _attachment.Name = _Filename _message.Attachments.Add(_attachment) _message.Body &= "&lt;p&gt;Attached file: " & _Filename & "&lt;/p&gt;" Else _message.Body &= "&lt;p&gt;File not attached: " & _Filename & " because file does not exists.&lt;/p&gt;" End If Next``` Did you see what changed? <code class="codespan">_attachment.Name = _Filename</code> So you can change the filename of the attachment that is set automatically to the name of the file you use as the attachment to something different by changing the Name property of the attachment. Great, now on to bigger and better things. Why is this important? I have no idea, I just wanted to share this with you guys. I guess it&#8217;s one of those things you are unaware of until you think you are going to need it and then have to look it up and then realize while writing a blogpost it is just stupid. That&#8217;s why writing technical blogs is so much fun and it makes you look stupid.

Read More...