Phil Factor's Phrenetic Phoughts

Simple-Talk columnist
The wilder shores of Transact SQL    Phil on Twitter   Phil on SQL Server Central"

Old Philip Factor's Almanac

Published Thursday, December 28, 2006 3:54 PM

My annual new-year's present to the SQL Server community is the Philip Factor Almanac of Prophesies for the coming year. Along with this blog will be an article which explains how it all came about, but here I'll explain a bit about the technical side.

Firstly, here is your Almanac, or Horoscope for this coming year

This is almost entirely a SQL Server application, with a very thin layer of PHP and ADO. The SQL Server source is too long to show in its entirity here....

...but can be accessed here

The code for this is very similar to last years' annual present, Phil Factor's excuse generator. In fact, all I did was to allow macros to be more than one character, because I was having difficulty keeping track of them.

At the heart of the Prophesies is a function that returns one of a list of phrases. (ufsOneOf) This is called by a function that contains a bank of cliches and commonly-used sentence components, according to the macro requested (ufsSelectRandomPhrase) which is, in turn, iteratively by another function (ufsWaffle) This latter function doggedly looks through a string pulling out the macros and getting them interpreted by ufsSelectRandomPhrase.

ufsWaffle is fed a series of lines from a datanase which contains a number of sentences.

This system is capable of a lot of elaboration. I've used it for substituting values into text from a lookup table for sending out emails, as well as generating plausible random text.

You might have thought that it would be all a lot easier using recursion. It may be that the code would be shorter, and possibly easier to follow, but it turns out to be rather slow.

Comments

No Comments
You need to sign in to comment on this blog

















<December 2006>
SuMoTuWeThFrSa
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456
A SysAdmin's Guide to Change Management
 In the first in a series of monthly articles, ‘Confessions of a Sys Admin’, Matt describes the issues... Read more...

Exchange: Recovery Storage Groups
 It can happen at any time: You get a request, as Admin, from your company, to provide the contents of... Read more...

Build Your Own Virtualized Test Lab
 Desmon explains the fundamentals of building a test lab for Windows servers and Enterprise applications... Read more...

Rendering Hierarchical Data with the Treeview
 It sometimes happens that Web Server controls that visualize data don't quite fit with the way that... Read more...

SQL Server 2008: Performance Data Collector
 With Performance Data Collector in SQL Server 2008, you can now store performance data from a number of... Read more...