|
 |
|
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 12/3/2008 11:13 AM
While Velocity supports tags, it's not an easy proposition. But with this quick function, you can fix that lack. Read More » | By CarpDeus on 12/2/2008 9:08 PM
So, I'm giving a talk next week in Dallas at VSLive and I'll be talking about Velocity. So, I'm building demos to talk about caching and I'm using SDS (MS... please keep the servers up for my talk). Read More » | By CarpDeus on 12/1/2008 5:22 PM
Read More » | By CarpDeus on 12/1/2008 10:20 AM
SQL Server is set based. Sometimes we get data that isn't. And, when that happens, we need to convert it. One way to do this is using a simple function like this one:
-- =============================================-- Author: Josef Finsel-- Create date: 2008-12-1-- Description: Split delimited list into-- generic single column rows-- based on passed in delmiter-- =============================================ALTER FUNCTION [dbo].[Delimited2Rows]( @DelimitedString nvarchar(max), @Delimiter char(1))RETURNS @HoldingTable TABLE ( IDColumn bigint identity primary key, DataColumn nvarchar(1024) )ASBEGIN while charindex(@Delimiter,@DelimitedString)>1 begin INSERT INTO @HoldingTable VALUES(ltrim(rtrim(substring(@DelimitedString,1, charindex(@Delimiter,@DelimitedString)-1)))) set @DelimitedString = substring(@DelimitedString, charindex(@Delimiter,@DelimitedString)+1, len(@DelimitedString)) end if len(@DelimitedString)>0 INSERT INTO @HoldingTable... Read More » | By CarpDeus on 11/21/2008 4:34 PM
Every now and again, you are doing something and you need a small screwdriver instead of a hammer. I've been working on a lot of repetitive API work where I end up copying a set of files, renaming them, and then editing them. While I should just write a factory to handle these things, in the meantime I wanted to simplify my rename of a batch of files. So I wrote a little console app for batch renaming (download an executable here). The whole of the code is only 60 lines and that's because I wanted to include a help. So, you can cut and paste from here if you want:
using System;using System.Collections.Generic;using System.Text;using System.IO;
namespace bRenamer{class Program{ static void Main(string[] args) { if (args.GetUpperBound(0) != 2) { System.Version AppVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; Console.Clear(); Console.WriteLine("{4}\tVersion: {0}.{1}.{2}.{3}", AppVersion.Major.ToString(),... Read More » | By CarpDeus on 11/20/2008 6:28 PM
So, I'm playing around with SQL Data Services (SDS), one of Microsoft's Cloud Databases. (see more here, signup forPublic CTP here). And it requires some shifts from the way that things are normally done. I've got a demo that I talk abouthere, but I've made some changes since then. The original demo only had one "table", a calendar of events. I've updated thatZip file to now include another "table". Read More » | By CarpDeus on 11/20/2008 4:02 PM
When is a UUID not a UUID? When it automagically changes case on you.
Mike Amundsen came to me with a minor gripe about being inconsistent with casing GUIDs coming from the database. He was getting lower case in the detail and upper case in the list. I didn't think I was doing that so I did a little bit of research. Microsoft, as can be the case when you're a very large company, is a bit inconsistent. According to the proposed standard (RFC-4122):
Each field is treated as an integer and has its value printed as a zero-filled hexadecimal digit string with the most significant digit first. The hexadecimal values "a" through "f" are output as lower case characters and are case insensitive on input.
And .NET does this correctly. Put the following code into a console app.
C#
string stringControlGUID = "4A71C777-1F6E-45D5-89D5-88CCE2AAD25B";Guid guidControlGUID... Read More » | By CarpDeus on 11/18/2008 10:10 PM
Read More » | By CarpDeus on 11/11/2008 3:00 PM
So, while the servers I run are all SQL 2005, I'm using the SQL 2008 tools for editing. Along with the inherent difficulties I find with Intellisense, there's another minor issue which turns out to be Virtual Space.
In Virtual Space mode, the Editor acts as if the space past the end of each line is filled with an infinite number of spaces, allowing code lines to continue off the side of the visible screen area. (MS Books Online)
Which means that my years of keyboard training require re-training. For instance, if I'm at the beginning of a line and want to go to the end of the previous line, hitting the left arrow key no longer works. Instead I need to hit up and then end. Also, if I click on a line and my mouse is over to the right part of the screen, my cursor ends up waiting for me to type with lots and lots of white space to the... Read More » | By CarpDeus on 11/10/2008 2:12 PM
I do a fair share of C# programming in my job, in addition to the database component. And I love using string.Format() to easily build strings. And I'm in the midst of a conversion project where I'm going to have a static chunk of XML that I'll need to use for every record getting converted, and string.Format comes to the rescue in an not so intuitive way. I'll build a string with the replacement tokens and use that string as the pattern for the format command. So it will look something like this:
StringBuilder XmlTemplate = new StringBuilder(""); int qID = 0; XmlTemplate.AppendFormat("[{1}]XmlTemplate.AppendFormat("[{1}]XmlTemplate.AppendFormat("[{1}]XmlTemplate.AppendFormat("[{1}]XmlTemplate.Append(""); XmlTemplate = XmlTemplate.Replace('[', '{').Replace(']', '}');
// while inside loop of conversion data string XmlToProcess = string.Format(XmlTemplate.ToString(), "first", "second", "third", "fourth"); MessageBox.Show(XmlToProcess );
The only real downside to... Read More » |
|
|
| |
|
|
|
|
|