|
 |
|
The Reluctant DBA |
 |
|
 |
| |
| Author: | CarpDeus | Created: | 4/18/2008 6:56 AM |  | | As a programmer and database administrator, I've seen a lot and here I'll record bits of information about what I'm doing and how I'm overcoming various challenges |
By CarpDeus on 7/22/2008 11:23 AM
One of the stated goals of Microsoft is that they make the plumbing easier for programmers. Rather than forcing us to build the intricate foundations, they provide tools like ADO.NET to make connecting to a database and manipulating/retrieving data a piece of cake.
Sometimes, however, you can encounter a problem that's beyond your ability to control because MS is being helpful.
I've got a very simple application. It's making a ADO.NET call to the database to execute a stored procedure. Occasionally, this times out. Now, you can tell me that the database was busy or there were blocking transactions or any number of other things, but I'll tell you the weren't happening. In fact, you could turn Profiler on and see the call being made from ADO.NET, see it taking an ungodly amount of disk reads and 30+ seconds. Consistently for a set of parameters.
Now, while the web page is spinning and waiting for a timeout, run the exact set of code in Query Analyzer. Runs in milliseconds, the way it should... Read More » | By CarpDeus on 7/16/2008 7:11 AM
I've had a version of the Cipher Sovler on the web for years. Now I have ported that to the Windows Mobile platform as well.
Simple? Yes. But ever so enjoyable. You can download a trial version here. It is remarkably similar to the web version, though scaled down to a much smaller screen size. This mean separating the functionality into three separate tabs. One to solve the puzzle:

One to Enter the puzzle:

And one for the statistics:

I need to see about setting it to change size and shape for auto-rotation and adding a time but that's for next week.
Read More » | By CarpDeus on 7/4/2008 6:55 AM
I've been playing around with writing a little application for my handheld, a version of the cipher solver on my personal site. And, to make it more interesting, I wanted to be able to see how long it took me to solve each puzzle. Not finding a good class to use, I wrote one myself using the TimeSpan class.
Let's first look at the global variables:
///
/// Starting time
///
DateTime startingTimer;
///
/// Total Ticks processed
///
Int64 totalTicks = 0;
///
/// Is the stopwatch currently running
///
public bool TimerRunning = false;
I think they are all fairly self-explanatory.
Now, the simple mechanics of starting and stopping the timer. There are four methods: StartTimer(), StopTimer(), PauseTimer() and RestartTimer(). The only difference between StartTimer() and RestartTimer() is that StartTimer() sets the totalTicks to 0. PauseTimer() actually just calls StopTimer(), which adds to the running tick count in totalTicks.
///
///... Read More » | By CarpDeus on 6/18/2008 8:02 AM
An Universally Unique Identifier (UUID) can be a handy thing to use. They are guaranteed to be unique across time and space (or very nearly so) and make great identifiers that you can be fairly sure won't be duplicated in another table like an Identity column can. But they do pose some challenges.
Empty UUIDs, for instance. C# can use Guid.Empty.ToString() to return 00000000-0000-0000-0000-000000000000. But it can be a pain having to type that out. So it's easy to create a UDF that will return an empty UUID:
-- =============================================
-- Author: Josef Finsel
-- Create date: 6/18/20008
-- Description: Return a zero filled UUID
-- =============================================
CREATE FUNCTION EmptyUUID
()
RETURNS UniqueIdentifier
AS
BEGIN
RETURN convert(uniqueidentifier, '00000000-0000-0000-0000-000000000000')
END
GO
However, I try not to use this in my actual code (see Why Functions Can Be Bad... Read More » | By CarpDeus on 6/11/2008 3:00 PM
I've learned many tricks over the years for dealing with dates in SQL Server. Today, one of my fellow developers came up to me and asked me how to handle string concatenation and, as it turned out, what he was trying to do was to get yesterday's date for filtering. Fortunately, this is something I've done a time or two before so I showed him this quick trick: select convert(datetime,convert(char(10),getdate()-1,101))
The innermost conversion changes the date to a truncated string of MM/DD/YYYY, which conviently removes any time and resets the date to Midnight. GetDate()-1 subtracts one day, another handy feature. Finally, just because SQL Server would do it itself but not necessarily as efficiently, convert the string to a date time. Which effectively changes 6/10/2008 16:08 to 6/10/2008.
| By CarpDeus on 5/29/2008 8:01 AM
This site, along with the others I maintain personally, run DotNetNuke. For those old enough to remember, DNN is based on IBuySpy, I actually work with one of the folks responsible for the original IBuySpy code and site. Recently, DNN announced a security issue and here, just a couple of weeks later, they had an upgrade ready to go. I personally like DNN. The modules and skins are easy to implement. I was able to take a couple of pieces of code I needed to handle WebQuotes and the like with very little work. It may not work for everyone and I still have some issues with my code I need to work through but it demonstrates that frameworks and open-source can work, even in the Microsoft World.
| By CarpDeus on 5/27/2008 8:08 AM
While I did have a relatively relaxing Memorial Day weekend, and did get to see Indiana Jones and the Crystal Skull, I also wrapped up the initial programming for SVN For SQL 2005.
| By CarpDeus on 5/23/2008 4:00 PM
While I will be spending time on a rented rowboat at the lake and doing some restful things, I think I know what I want to do about creating SVN-able files from the database. Over the weekend I'll probably put together a little utility that will take basic user information and connect to a database and dump out views, sprocs, udfs, uddts, tables and such using SQLDMO to directories where it can be used for source code control with SVN. I'll probably CCL the code or something. Til next week Josef
| By CarpDeus on 5/21/2008 8:19 AM
SQL Server 2005 does interface with Visual Source Safe. Which is, I suppose, a good thing.
But I hate VSS. Never truly liked it and, when I was introduced to SVN a few years back, did my best to give up VSS entirely. I've got an SVN server where I put all my important stuff and use Tortoise SVN as my interface. Quick, simple, mergeable... In short, many things that VSS isn't.
And I recently installed SP2 for SQL 2005 which FINALLY allows for scripting of database objects to seperate files again. So the first thing I did was dump databases out to directories as individual files and SVN them. Which was good. But there's no good way to say to the Script Wizard, "By the way, old chap, I'd like to just create those scripts for objects changed/created since this date." So I think I may write something, unless someone can point me to code that already does that. I'll use the DMO to create the script objects, that's for sure, but, until that time,... Read More » | By CarpDeus on 5/16/2008 1:06 PM
I actually wrote this some time ago but wanted to share it here as well.... This title and an appropriate picture, were on a co-worker's cube and so I said to him Read More » |
|
|
| |
|
|
|
|
|