Category Archives: SQLServerPedia

Appending New Rows Only

I saw a question in the forums related to inserting new rows into a SQL Server table only if they didn’t exist. The current solution was using an ADO.NET DataTable , checking for new rows and then pushing the rows back to SQL Server by calling the Update method on the DataAdapter. Although the solution…

Backup Database Object

I saw this question in one of forums on backing up i.e. scripting out a database object. The problem is easy to solve, but only if you’re familiar with SMO . Even so, there some more obscure aspects of SMO like URNs which not many people are aware of. If you read the MSDN docs…

Table-Valued Parameter Example

I wanted show someone how to use table-valued parameters available in SQL Server 2008 and higher. The main use case of table-valued parameters is for sending a list or array of items as parameter to a SQL Server stored procedure or function. This is more efficient than parsing strings or XML on the SQL Server…

Transforming Event Log Data

Several months ago I described a solution for Delegated SQL Server Administration with Powershell. In the solution, the SqlProxy module audits all security administration activity to a custom Windows Event log. In this blog post, I’ll described a process to transform and incrementally load the audit data into a SQL Server table for reporting purposes….

Reconciling SPNs

As part of troubleshooting Kerberos authentication for SQL Server I had to verify SPNs so I thought I’d blog about the process I went through. Sometimes I think a post blog is nothing more than public documentation of  a complex problem … Get SQL Server SPNs from Active Directory Before Powershell I would use the…

Sharing Profiles

A question came up in a class I was teaching:  “How do you share your Powershell profiles across accounts?” Well, there’s documented way of sharing profiles on the same machine where you create an All Users profile. As stated in help about_Profiles Powershell will look in the following locations for profiles: Name Description ———– ———–…

Sarasota IT Pro Camp

Join system administrators IT professionals and database professionals in addition to managers at all levels who work with Microsoft technologies for the Sarasota IT Pro Camp on Saturday, February 18th, 2012. IT Pro Camps are focused on serving the needs of  IT Pro’s (Windows system administrators). IT Pro’s haven’t had many events like our developer counterpart’s…

Orlando IT Pro Camp

The Orlando IT Pro Camp marks our third event after Tampa and South Florida. As with the prior IT Pro Camps I’m helping put together the Orlando IT Pro Camp. Register to attend this free event on Saturday, January 21st. Orlando will be even bigger than Tampa or South Florida with 30 sessions on topics…

Importing CSV Files to SQL Server with PowerShell

Ed Wilson (Blog|Twitter) aka Scripting Guy is kicking off another guest blogger week  (Nov 28th 2011) with my guest blog post, Four Easy Ways to Import CSV Files to SQL Server with PowerShell. The post demonstrates the following approaches to importing CSVs into a SQL Server table: T-SQL BULK INSERT command LogParser command-line LogParser COM-based scripting…

Some SQL Server Security Housekeeping

Managing SQL Server security changes in mass is something which screams automate it. Let’s look a at few examples using either T-SQL, a Centeral Management Server and Powershell. Task #1 Remove a SQL Server Login from the Sysadmin Role Let’s say you’re given the task to remove a login from the sysadmin role on 50…