Say that 5 times fast…
Sometimes, you have checked all the tables and views and you cannot find the information you are looking for. You know someone ran a command that messed things up, you don’t want to place blame, you just want to know WHEN it happened. Your last resort is searching the cached query plans. You are hoping this was an ad-hoc plan. Here is a quick way to find a value in the query plans:
SELECT top 10 *,
p.query_plan.value('
declare namespace SHPL="http://schemas.microsoft.com/sqlserver/2004/07/showplan";
(/SHPL:ShowPlanXML/SHPL:BatchSequence/SHPL:Batch/SHPL:Statements/SHPL:StmtSimple/@StatementText)[1]
','varchar(max)') as StatementText
FROM sys.dm_exec_query_stats s
CROSS APPLY sys.dm_exec_query_plan(s.plan_handle) AS p
WHERE
p.query_plan.value('
declare namespace SHPL="http://schemas.microsoft.com/sqlserver/2004/07/showplan";
(/SHPL:ShowPlanXML/SHPL:BatchSequence/SHPL:Batch/SHPL:Statements/SHPL:StmtSimple/@StatementText)[1]
','varchar(max)')
like '%CREATE TABLE%'
ORDER BY s.creation_time DESC
I am working on my Facebook game, I am currently working with the title “Cavern Hunter”, but this might change to “Dungeon Designer” or something like that. It is roughly modeled on the mechanics of another Facebook game called Exile Gods. I plan to use the same card game crafting type system but it will be different enough that I while similarities can be discussed, it will have totally different gameplay.
Tags: facebook
Do you have a server that has been a repository for stored procedures for more than 10 years… Do you even know if all the procs are used, let alone whether they still work after databases have moved, changed names/schemas, had columns refactored and renamed? Here is a handy little program for you. I called it DbValidator and essentially what it does is run through all of the stored procedures and views of a database and spit out errors on those that do not compile. It makes use of the T-SQL feature: “SET NOEXEC ON” to re-compile each proc and view and give you the results. I made this into a console application that is run like this:
dbvalidator.exe @Server @Database > @Output File as Text
Give it try and leave me comments, thanks.
Download DbValidator.zip
Step One was organizing what room is what. Here is a crude (sorry it isn’t to scale) diagram of my basement. I have labeled each room. One thing I have also decided is to put all tools in the garage and not have any tools inside the house. This frees up the work room for other things.
One of them currently being storage for over thirty boxes of comic books I am trying to sell. If you are interested, look on Atomic Avenue.
Another is to set up a workstation for designing chainmaille jewelry, a small hobby that I picked up that I want to pursue. Again, you can see some of this over at Quinn’s Emporium. This workstation might also double as a painting station for miniature painting. The room has a single small window for ventilation, so I should be okay for that.
The pantry room is probably the most problematic to figure out. It has shelving on two walls that make it work as a pantry, but a lot of open space (once the comic books are removed), so I am not sure what to do about this open space, perhaps some cheap shelving units?
Anyways, next post I will have pictures of each room to show the mess and what I am currently trying to tackle…
- Blog daily – Not really doing well here, missed all of February…
- While blogging, try to ignore that someone else may have already done an article about this topic – Still having trouble with this one. I need to just post cool stuff that I did…
- Make a calendar of daily, weekly, monthly and yearly chores and try to stick to it. I half made this list, but it is being worked on.
- Play at least two new boardgames a month. Didn’t get this done in January or February, here’s hoping for March!
- Post at least one SQL article a week about something I have worked on or think is cool. Once a week, not so much, but I do have some articles in planning stages…
- Read a book a week and a book a day to the kids. Reading to the kids is going ok, more like a book a week to the kids and a book a month for me (I read the Percy Jackson books…)
- Develop two boardgames this year. This one is going okay. I have two prototypes and about six designs on paper. This one may actually happen!
- Develop a Facebook app even if it is only for my enjoyment. This might be a mid-season drop from my resolutions, but I am hoping to collaborate with my brother-in-law on this one…
Inspired by this Unclutter post, I thought I would start a Project: Basement of my own. I am giving myself to the end of the month to achieve the same goal that Erin is giving a week. My first tasks mirror those in the article:
- List of what is in each room (my basement consists of five distinct rooms + garage)
- Goal for each room (what do I want each room’s function to be at the end)
- Assemble boxes for donation/sale/consignment
- Make a list of simple chores to get the ball rolling.
One of the things we have found when doing maintenance is to make sure no jobs kick off in the middle of our manual maintenance tasks.
SELECT * INTO msdb.dbo.sysjobs_temp FROM msdb.dbo.sysjobs
UPDATE msdb.dbo.sysjobs SET enabled = 0
Then, when you are finished:
update sj
set sj.enabled = sjt.enabled
from msdb.dbo.sysjobs sj join msdb.dbo.sysjobs_temp sjt
on sj.job_id = sjt.job_id
If you are re-attaching databases after a SQL 2008 upgrade, here is a quick n dirty T-SQL command to upgrade to the the correct compatibility level, just run, copy the results and run those:
select 'ALTER DATABASE [' + [name] + '] SET COMPATIBILITY_LEVEL = 100'
from master.dbo.sysdatabases










