Thursday, December 30, 2010
Error Accessing SharePoint 2010 ListData.svc 'System.Data.Services.Providers.IDataServiceUpdateProvider' from assembly 'System.Data.Services, Version=3.5.0.0
when attempting towork with SharePoint 2010 WCF Services you need to install one of the following hotfixes:
ADO.NET Data Services Update for .NET Framework 3.5 SP1 for Windows 7 and Windows Server 2008 R2
ADO.NET Data Services Update for .NET Framework 3.5 SP1 for Windows 2000, Windows Server 2003, Windows XP, Windows Vista and Windows Server 2008
Don't forget to download the x64 executable! And on a side note, I did have to restart my development system. Just a reset of IIS was not enough.
Thursday, December 16, 2010
Creating a Drag-and-Drop Upload Web Part for SharePoint Foundation 2010
Setting an Environment Variable to the "14 Hive"
The solution? Create an environment variable mapped to the location.
"C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN"
On Windows 7 right click "Computer" and select properties or in the search field type "System" and under Control Panel select "System". Click Advanced System Settings and Environment Variables. Click "New" under user variables. Then enter the alias you wish to give the path in Variable name (I normaly use just 14) and copy and paste the value in the code block above into the Variable value field. Start a new CMD session and test by typing
C:\> echo %14%or open a run box and type %14%.
Wednesday, November 10, 2010
Finding Size Information for the Content of your WSS 3.0 Webs/Lists
USE [WSS_Content] GO SELECT [dbo].[Webs].[FullUrl] ,[dbo].[Lists].[tp_Title] AS "ListName" ,[dbo].[Docs].[DirName] ,[dbo].[Docs].[LeafName] ,[dbo].[Docs].[Size] ,[dbo].[Docs].[MetaInfoSize] ,[dbo].[Docs].[Version] ,[dbo].[Docs].[TimeCreated] ,[dbo].[Docs].[TimeLastModified] ,[dbo].[Docs].[MetaInfoTimeLastModified] ,[dbo].[Docs].[CheckoutUserId] ,[dbo].[Docs].[CheckoutDate] ,[dbo].[Docs].[ExtensionForFile] FROM [WSS_Content].[dbo].[Docs] INNER JOIN [WSS_Content].[dbo].[Webs] ON [dbo].[Webs].[Id] = [dbo].[Docs].[WebId] INNER JOIN [WSS_Content].[dbo].[Lists] ON [dbo].[Lists].[tp_ID] = [dbo].[Docs].[ListId] WHERE [dbo].[Docs].[Size] > 0 AND ([dbo].[Docs].[LeafName] NOT LIKE '%.stp') AND ([dbo].[Docs].[LeafName] NOT LIKE '%.aspx') AND ([dbo].[Docs].[LeafName] NOT LIKE '%.xfp') AND ([dbo].[Docs].[LeafName] NOT LIKE '%.dwp') AND ([dbo].[Docs].[LeafName] NOT LIKE '%template%') AND ([dbo].[Docs].[LeafName] NOT LIKE '%.inf') AND ([dbo].[Docs].[LeafName] NOT LIKE '%.css')
Tuesday, November 9, 2010
PowerShell Script to Monitor the Status of a SQL Job
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.ConnectionInfo") [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") $server = new-object "Microsoft.SqlServer.Management.Smo.Server" "localhost" $job = $server.JobServer.Jobs["Test Job"] $now = Get-Date do { Start-Sleep -Seconds 1 $job | select Name,CurrentRunStatus,LastRunDate $job.Refresh() } while($job.LastRunDate -lt $now) $job | select Name,CurrentRunStatus,LastRunDate
Saturday, October 30, 2010
PowerShell Scripts to Continuously Ping a Host and Give an Audible Alert
#Used to continuously ping a host and get an audible alert when it is back up. function ContinuousPing-Beep { param([string]$computer) $ping = new-object System.Net.NetworkInformation.Ping $result = $ping.Send($computer); if($result.Status -eq "Success") { Write-Host "Reply received from $computer" -Foreground green Write-Host `a; } else { do{$result = $ping.Send($computer);Write-Host "Reply from $computer. Destionation host unreachable." -Foreground red} until($result.Status -eq "Success") Write-Host "Reply received from $computer" -Foreground green Write-Host `a; } } function ContinuousPing-Voice { param([string]$computer) $voice = new-object -com SAPI.SpVoice $ping = new-object System.Net.NetworkInformation.Ping $result = $ping.Send($computer); if($result.Status -eq "Success") { $voice.Speak("Reply received from $computer", 1) } else { do{$result = $ping.Send($computer);Write-Host "Reply from $computer. Destionation host unreachable." -Foreground red} until($result.Status -eq "Success") $voice.Speak("Reply received from $computer", 1) } } ContinuousPing-Beep "192.168.1.1" ContinuousPing-Voice "192.168.1.1"
Tuesday, October 5, 2010
How to determin if you are logged in via Kerberos or NTLM on SQL Server
SELECT c.session_id ,s.login_name ,c.auth_scheme ,c.net_transport ,s.host_name ,s.login_time FROM sys.dm_exec_connections c INNER JOIN sys.dm_exec_sessions s on s.session_id = c.session_id
Tuesday, September 14, 2010
BDC in SharePoint 2010 Foundation for a Department Level Database
Monday, September 6, 2010
PBM and ExecuteWQL()
http://msdn.microsoft.com/en-us/library/aa394606(VS.85).aspx
http://msdn.microsoft.com/en-us/library/bb895209.aspx
http://sqlserverpedia.com/blog/sql-server-bloggers/executewql-in-policy-based-management/
Sunday, September 5, 2010
SQL Server 2008 Extended Events
Sunday, August 29, 2010
Creating a Basic CLR Stored Procedure Using C# in Visual Studio 2010
I was recently confronted with a problem managing a database of MAC addresses. Our company purchased a block of MACs and our team was tasked with the problem of creating the database and associated services for managing the MAC range.
The problem was that there did not seem to be any way to easily convert from decimal integer types to hexadecimal in T-SQL. One possible way to solve this problem is to write a simple C# CLR stored procedure as this type of conversion is pretty trivial in languages like C#.
This tutorial assumes you will be adding the CLR stored procedure to the AdventureWorks 2008 database and that you will be using SQL Server 2008 R2.
Step 1 – Enabling CLR in SQL Server
Run sp_configure to enable CLR on your test SQL Server Instance.EXEC sp_configure 'clr enabled', 1 GO RECONFIGURE GO |
Friday, August 20, 2010
Refocusing on Studies and Blogging
It has been a crazy couple of months. I have actually gotten my dream as a SQL Server and SharePoint admin/developer. I cannot explain how happy this has made me and I have been working hard to fill in the gaps in my knowledge. Now that I'm more settled in, I'm trying to get back on track as far as my studies go and take the dang upgrade exam for the MCITP DBA 2008. I know I am pretty much ready for the test. I think with a good review of mirroring and replication I could pass without really doing any prep. So I am hoping to schedule this exam as soon as possible.
I use certification to both focus and measure my studies on a given topic. There are a couple of other areas that I need to explore and I am going to pursuing the following certifications in the next 6 months as well:
- MCITP: SharePoint 2010 Administrator (70-677 | 70-668)
- MCTS: SQL Server 2008, Business Intelligence Development (70-448)
I'm really hoping to be able to accomplish these quickly and be able to share some details about my studies and some of the very interesting things that I have going on at work.
Tuesday, August 17, 2010
The Power of Stupid...
It was not until I wrote the same code in PowerShell that I actually got an error that made sense: “Access Denied.” I mentioned this to my boss who asked me which domain I was logged in under. Then I typed whoami and quickly realized what a dummy I had been.
Saturday, August 14, 2010
Chinook Database on CodePlex
Thursday, July 8, 2010
How to Remove Some Thing from a Column’s Data
Here was a problem I was faced with today. A friend of mine was experiencing issues with two databases not syncing properly because one had a column (City) that contained a special character (a single quote). We needed to craft a query that would remove the single quote without changing any other portion of the column's data. There were two considerations that needed to be made:
- Ensuring the single quote was properly escaped so that it did not cause an error at run time.
- How to properly place the REPLACE function inside the UPDATE command.
UPDATE [ARCUSTOMERS] SET City = REPLACE(City, '''', '') FROM [ARCUSTOMERS] WHERE City LIKE '%''%' |
Tuesday, July 6, 2010
Getting Back to Basics
Fundamentals of Relational Theory and Database Design
Fundamentals of T-SQL Querying (2005 and 2008)
T-SQL Queries and DMVs
The third item is really one of my favorites, but I feel I have not put as much effort into it as I should.
Wednesday, June 30, 2010
Excel Services and PowerPivot for BI
Tuesday, June 29, 2010
Stupid SharePoint 2010 Error:The Installation of this Package Failed
Monday, May 3, 2010
Using sp_executesql for a Script Based “Function”
DECLARE @myVar AS INT DECLARE @test AS nvarchar(500) DECLARE @paramDef nvarchar(500) SET @paramDef = N'@myParam INT' SET @myVar = 10248 SET @test = N'USE Northwind; SELECT * from dbo.Orders where dbo.Orders.OrderID = @myParam' EXEC sp_executesql @test, @paramDef, @myParam = @myVar; |
The syntax is explained below.
EXEC sp_executesql @variable, --This represents the SQL code to be executed. @parameterDifinition, --This describes the parameter. Is it a varchar, -- int, or some other type. @valuePassed --This holds the value you wish to pass to the -- parameter. |
Friday, April 30, 2010
Virtualization and SAN Basics for the DBA
Friday, April 9, 2010
SQL PowerShell Extensions - SQLPSX
I have been working with PowerShell for a while now and have been writing my own custom tools. I have used it to implement log shipping on a SQL 2000 Server, I use it to dump things to a WSS site, and I use it for a number of management tasks. Sometimes it can be a PITA as you find yourself writing your own functions and "modules" to do simple, repetitive tasks.
Well the guys in the SQLPSX team on CodePlex have just made my life so much easier and I wanted to make sure my readers (my wife and apparently a couple guys in India according to Google Analytics) were aware of the tools that SQLPSX provide. These are simple, easy to use PoSh modules that can take objects via the pip-line like almost any other command let in PoSh. Make sure you add it to your tool box! Chris Barth did a nice presentation on it at the local PASS chapter meeting at MAXTrain in Mason, OH and it was also written up in last month's SQL Server Mag.
Thursday, April 8, 2010
SQL Server 2008 DBA Exam Resources
I'm breaking this post up into three parts. The first is books that I have used to study for the DBA Upgrade exam and that I believe are perfect for preparing for any of the DBA exams for SQL Server 2008. The second section is for training material I have found on the web. The third section is for books that I believe are good to read for a career as a DBA. If you already work with SQL Server these books will help you get to the next level.
Section One – MCITP: DBA 2008 Books
SQL Server 2008 Administration in Action
SQL Server 2005 DBA Street Smarts: A Real World Guide to SQL Server 2005 Certification Skills - While this book is for SQL Server 2005, all of it is applicable to SQL Server 2008. Learn how to do all of the exercises in this book and know them cold and you will be at a very strong junior level.
If you study these two books and know how to do all of the labs in them in the GUI and via T-SQL you will be a very competent SQL Server professional.
Microsoft SQL Server 2008 Fundamentals – This will set you up to have a strong fundamental understanding of T-SQL and how it works.
These three books lay the foundation for becoming a very strong SQL Server IT Pro. But I cannot stress that you cannot just read them for this to be true. You need to make these as hands on and practical as possible. Do every single exercise you can. Retype every single line of code and run it.
Section Two – Online Resources
BoL 2008
SQLServerPedia
SQL Server 2008 Virtual Labs
SQL Server 2008 How To Videos and other Resources
Section Three – Beyond the Certification
DBA Survivor: Become a Rock Star DBA – Advice and information to help you get and keep your first job a s a full-time DBA.
SQL Server 2008 Troubleshooting and Internals
SQL and Relational Theory – Learn the fundamental concepts of Relational Database theory and how to apply it to your T-SQL.
Beginning Database Design: from Novice to Professional
SQL Server MVP Deep Dives – Advice and knowledge from the best professionals in the field.
Monday, April 5, 2010
DMVs Related to Disk I/O
Objective: Designing a Monitoring Strategy
Sub-objective: Design a monitoring solution at the operating system level
This is a list of DMVs I have encountered in my studies of I/O as it pertains to SQL Server. I have included a brief description from the MSDN article as well as link to the article itself. These will be highly important, not only from a certification level, but also from a practical level. This list is in DBA Survivor by Thomas LaRock and many of them are also found in sources like SQL Server 2008 Administration in Action by Rod Colledge and the chapter entitled My Favorite DMVs and Why by Aaron Bertrand in MVP Deep Dives.
Wednesday, March 31, 2010
Sp_Configure Options
EXAM Objective: Installing and Configuring SQL Server 2008
Sub Objective: sp_configure
Sp_Configure Options
In a previous post I discussed sp_configure and how to use it. In this post I will be covering some of the options and their meanings. Many of the meanings are pretty straight forward but a few of them are a bit obscure. The options I will be looking at now are listed below. These are either options I have come across in preparation for the SQL Server 2008 MCITP certification or that I felt might be of practical value to know.
- cost threshold for parallelism
- max degree of parallelism
- max server memory (MB)
- min server memory (MB)
- index create memory
- min memory per query
- AWE enabled
- ad hoc distributed queries
- filestream access level
- backup compression default
Thursday, March 11, 2010
Using MAX(datetime) and Sub-Queries to Find the Most Recent Item
Today I was preparing a query that pulled some information from the inventory and sales tables of our ERP. The query itself was pretty easy to craft, but the VP of Sales threw a wrench into the mix; it should only contain information regarding the most recent sales order. Let's imagine my query was providing output like this table. Of course the actual query was more complex, but this gives the important information to understand the problem.
Part_No | Rev | On_Hand | Safety_Stock | SO_No | SO_Date |
12345 | A | 10 | 15 | S1234 | 12/14/2009 |
12345 | A | 10 | 15 | S1233 | 10/01/2009 |
12345 | A | 10 | 15 | S1232 | 08/02/2009 |
12346 | 5 | 0 | S1231 | 08/01/2009 | |
12347 | - | 0 | 0 | S1230 | 10/20/2009 |
12347 | - | 0 | 0 | S1229 | 07/15/2009 |
What I actually needed the query to deliver were lines 1, 4, and 5. These are only the most recent sales orders associated with each part number.
Friday, March 5, 2010
Removing Duplicate Items from an Array in PowerShell and C#
As a DBA I sometimes have to do some programming or scripting. One of the things that I find very useful is knowing how to remove duplicate items from an array. Most recently I had a C# application I had built that was generating duplicate items (they weren't really duplicates the part numbers were the same, however the revision was different. But the fact that the rev was different was irrelevant to the people consuming the data. Now one of the fields I needed to select was of the text data type, so I could not include DISTINCT in the query's select clause. I had to remove the duplicates from the array holding the data set. The .NET Framework 3.5 had made this a snap. You used to have to loop through the array and perform a comparison, but now you can do it with just a single line of code!
Monday, February 22, 2010
Simulating Log Shipping with Windows PowerShell
In addition to changing the backup plans so that we are doing t-log backups every hour and adding alerts, operators, and notifications tot he server I started kicking around teh idea of using transaction log shipping to add an extra layer of protection to the system. But the issue was the production database server is SQL Server 2000 Standard, which does not include log shipping.
I decided to write a PowerShell script that would use the backups I was alreeady creating to simulate log shipping to a warm standby server. Here is what I have so far.
Tuesday, February 9, 2010
Creating a SQL Server 2008 Cluster in a Test Lab
Wednesday, January 13, 2010
Installing and Configuring SQL Server 2008: sp_configure
EXAM Objective: Installing and Configuring SQL Server 2008
Sub Objective: sp_configure
name | minimum | maximum | config_value | run_value |
access check cache bucket count | 0 | 16384 | 0 | 0 |
access check cache quota | 0 | 2147483647 | 0 | 0 |
Ad Hoc Distributed Queries | 0 | 1 | 0 | 0 |
affinity I/O mask | -2147483648 | 2147483647 | 0 | 0 |
affinity mask | -2147483648 | 2147483647 | 0 | 0 |
…. | ||||
locks | 5000 | 2147483647 | 0 | 0 |
max degree of parallelism | 0 | 64 | 0 | 0 |
max full-text crawl range | 0 | 256 | 4 | 4 |
max server memory (MB) | 16 | 2147483647 | 2147483647 | 2147483647 |
max text repl size (B) | -1 | 2147483647 | 65536 | 65536 |
max worker threads | 128 | 32767 | 0 | 0 |
… |