Inside the tent....

Occasional Editorial announcements.

  • Pasting code into a Blog.

    Posted Tuesday, July 15, 2008 8:45 AM | 1 Comments

    One reason that I often hear for the apparent inability of certain people to blog is that there is no way for Community Server to display code. It isn't actually that hard. The obvious choice is to use Phil Factor's prettifier. It is the reason he wrote it. If you need to show exactly what is in Visual Studio, or SSMS, there is another way.

    The problem you have is that Community Server is usually set to only allow FONT tags to enhance text. This makes life difficult, though it ensures that a blogger can't cause too much havoc with surrounding parts of the page.

    Paste your code into Word. Make sure that it has pasted it in, using the 'keep source formatting' option. Then, save it as HTML. Alternatively, you can use Outlook. (I set the format of the message to be HTML. I then send the code to myself, right-click the results and select 'view source code'.)

    I then take the HTML code into a nice text editor, 'top and tail' it (take out the HTML, BODY tags and the DIVs, leaving just the Ps in place)  and do the following substitutions with the objective of taking out the SPANs (no need really as they don't get rendered anyway) and changing the Ps into BRs

    FROM TO Result
    style='font-size:11.0pt;font-family:"Courier New"' Deleted all occurences
    </p>\r\n<p class=MsoNormal <BR (this is RegEx) correct the spacing between lines. replace all paragraph tags with line break tabs

    You may find that the font has been styled for a different size, depending on the setting in Visual Studio. This means that yo will need to remove style='font-size:10.0pt;font-family:"Courier New"' rather than 11.0pt.

    Then create, or edit, the blog. Paste the modified code into the HTML pane (the tab is on the bottom-right of the panel in Community server) Select the code and, in the design pane, make the size of the code 2 rather than 3. Select the code and specify that it should be Courier

    All that we're actually doing here is trying to remove all the Word silliness of trying to be all things to all men. All you actually need is the colour information and the non-breaking spaces to do the indentation. The final substitution makes the paragraph tag render as you want it to.


    ALTER Function [dbo].[ufsRemoveDelimited]
        (
          @String VARCHAR(MAX),
          @OpeningDelimiter CHAR(1),
          @ClosingDelimiter CHAR(1)
        )
    RETURNS VARCHAR(8000)
    AS BEGIN
        DECLARE @newString VARCHAR(8000)
        IF @OpeningDelimiter = @ClosingDelimiter
            BEGIN
                RETURN NULL
            END
        IF @OpeningDelimiter + @ClosingDelimiter + @String IS NULL
            BEGIN
                RETURN @String
            END
        SELECT  @NewString = ''
        SELECT  @newString = @newString + SUBSTRING(@String, number, 1)
        FROM    numbers
        WHERE   number <= LEN(REPLACE(@string, ' ', '|'))
                AND CHARINDEX(@OpeningDelimiter, @string + @OpeningDelimiter,
                              number) < CHARINDEX(@ClosingDelimiter,
                                                  @string + ' '
                                                  + @closingDelimiter, number)
                AND number <> CHARINDEX(@OpeningDelimiter, @string, number)
        RETURN @NewString
       END


    Here is some C#, copied out of Visual Studio 2005


    // Marshal.cs
    using System;
    using System.Runtime.InteropServices;
     
    class PlatformInvokeTest
    {
        [DllImport("msvcrt.dll")]
        public static extern int puts(
            [MarshalAs(UnmanagedType.LPStr)]
            string m);
        [DllImport("msvcrt.dll")]
        internal static extern int _flushall();
     
     
        public static void Main()
        {
            puts("Hello World!");
            _flushall();
        }
    }


    Here is a small sample of VB code


    Private Sub Button1_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click
     
        ' Stores the return value.
        Dim RetVal As Integer
        RetVal = MBox(0, "Declare DLL Test", "Windows API MessageBox", _
            MB_ICONQUESTION Or MB_YESNO)
     
        ' Check the return value.
        If RetVal = IDYES Then
            MsgBox("You chose Yes")
        Else
            MsgBox("You chose No")
        End If
    End Sub

  • RSS feeds on the site

    Posted Thursday, April 17, 2008 4:01 AM | 0 Comments

    There a number of RSS feeds on the Simple-Talk site. For historical reasons, these feeds are tucked away in a number of different places on the site. Just for convenience, I'm putting them here.

    Each blogger actually has his own feed, but I've only listed the three most prolific bloggers.

  • A Prompt Delivery

    Posted Wednesday, April 02, 2008 3:57 AM | 1 Comments

    I wandered into Red-Gate's offices the other day. I'd been momentarily distracted by the autumn leaves, thoughtfully strewn in the hallway, probably by a visiting Zen Buddhist to remind us of the sacred presence of nature even in the Techno Park. Suddenly I was waylaid by the charming Tanya to take part in a bug-hunt. Somehow, I found myself in a room full of laptop computers and various developers, varying from the apprehensive (SQL Prompt developers) to the smug (ex-SQL Prompt developers).

    We were giving SQL Prompt 3.8 RC a quick post-test check-over before the new release candidate version of 3.8 is made available.

    The interesting thing about SQL Prompt 3.8 is that it is now using the code reformatter from SQL Refactor to lay out your SQL code nicely. This means that, for the first time, even the users of Query Analyser now are able to reformat code automatically. There are twenty different aspects of the reformatting you can change, in four different sections. It is a very clever piece of code that, for me, doubles the usefulness of SQL Prompt.

    There are one or two other features that are less immediately exciting than the reformatting code but would make a big difference to me. One of these is the 'tooltips'-style help for whatever object that you rest the mouse pointer over. Wonderful. I'm an old-stager with IDEs. I like a nice clean window free from clutter, and loathe having to do incessant clicking in the Object Explorer to do stuff. This is why I reach for such old-time practices such as sp_help and sp_helptext. If SQL Prompt can help me keep the clutter away so I can remind myself of the parameters to a routine or the columns of a table without having to scrub what's in the results window, then that's a real bonus. Other new features include Object Definitions, and a new Summary view in the schema panel.

    SQL Prompt is one of those product that one can love, but never unconditionally. There are so many different ways that Database Developers work and it is presumptuous to think that it could ever be possible to construct a tool that would satisfy everyone. Perhaps that is why Microsoft have taken so long to provide intellisense for SQL Server developers. It has to work for such a diverse community of users. However, by diversifying into managing layout, and providing all these nice features for even those unfortunates still wrestling with SQL Server 2000, SQL Prompt's future is assured, whatever arrives by way of intellisense in SQL Server 2008.

    I found SQL Prompt irritating to use until I adopted the obvious strategy of setting the triggering to manual (this should have been the default). Now you just invoke SQL Prompt just at the point of those senior moments when you forget the name of the table, routine or parameter. Another handy feature is being able to limit the trigger words that invoke SQL Prompt. There is a bit of work to do in order to make it function the way you want but the effort is worth it.

    The Red-Gate bug-hunts are good fun for the huunters, but painful for the application developers whose work is being treated the same way as a fox by foxhunters. TallyHo! I sat next to a developer who had the habit of throwing his head back and laughing in an evil gloating way every time he found a bug. I gazed in wonderment at the restraint shown by SQL Prompt's developers whose welcoming smiles only glazed over momentarily in response to the baying pack of bug-hunters, as they pushed firmly into the back of their minds any homicidal instincts towards the gleeful bug-hunters 'on the scent'. There is a certain etiquette in conveying the news to a hard-working developer that there is a tiny flaw in his masterpiece. Perhaps the pretence of amazed surprise that such a thing could possibly exist. Certainly, gloating or reproach is not an option, especially if, one day, the roles will be reversed, and it is your software being torn to shreds.

    Fortunately, the software worked surprisingly well for a beta (it is now a release candidate as I write - 2nd April 2008) so we're getting it ahead of schedule. I, for one, will be pestering the developers over what I see as its little quirks and irritations, but I'm fully expecting people on The Red-Gate Product Forumpraising the very features I find irritating. That's all part of the software development process, I suppose

  • Coram magnificos manifeste scalpere nolis ...

    Posted Wednesday, February 27, 2008 4:56 AM | 1 Comments

    'Coram magnificos manifeste scalpere nolis
    Torquendo digitos nares…'

    Daniellis Becclesiensis c1200 AD

    (meaning: Do not pick your nose in front of managers)

    One of the delights of being Simple-Talk’s subeditor, under the watchful eye of Tony (sir), Anna and Simon, is to interact with our team of regular writers. When I use the word ‘Team’, I do so rather loosely, as writers come and go under the influences of the pressures of other work, or life events. By a strange coincidence we see the return of two regulars to the team after a gap of two years.

    This issue welcomes back Amirthalingam Prasanna. Prasanna last wrote for us two years ago, and his five articles, with their clear tutorial style, have always been popular. He has returned with an update of his .NET Collection Management 08 December 2005  , called .NET Collection Management with C# We’d particularly like to cover Entity Framework on Simple-Talk, and we’re hoping that Prasanna will continue his output with a Cribsheet on the subject.

    Richard Morris, being a professional journalist, does not suffer from the need for pencil-chewing and inspiration that affects most of our authors. He needs no encouragement: his articles are there, on time, every time, and are always stimulating to read. He writes best when he feels a genuine indignation about the subjects of his investigation, and in this article, where he investigates the troubling fact that almost all the British government IT contracts go to a handful of enormous multinational IT companies, the heat is palpable.

    Phil Factor is not the most malleable of authors. Articles arrive with a quiet apology like ‘I know you wanted an article on maintenance plans, but this one just popped out.’ The article will be a mock pantomime, an elegy on indexes written in the style of Tennyson, or a treatise on the difficulties of running a project, written in the style of GK Chesterton. I have before me Phil’s translation of Machiavelli, rewritten very slightly and chillingly contemporary. Also Phil’s translation of the mediaeval (twelfth century) latin poem ‘Urbanus Magnus’, by Daniellis Becclesiensis, phrased for the modern office-workers, from which I have taken the quote that starts this Blog.. It means ‘Do not pick your nose in front of managers’. (literally ‘In front of grandees, do not openly evacuate your nostril by twisting your finger’). Other advice from the great work includes ‘if the wife of your manager attempts to seduce you, feign illness, as this is a no-win predicament for you.’. It is the first book of etiquette ever written in Western Europe.

    Under Robyn’s restraining influence, Phil’s work is more sober, and more consistent. Robyn is now on maternity leave but we are very fortunate that she continues to produce her articles for us, somehow taming Phil’s creative spirit. ‘The Alerts, Soup to Nuts’ is their first attempt at a ‘Soup to Nuts’ article. It all seemed so easy at first, evidently, but the more they got into the subject, ran tests and so on, the more they realised how little they understood of the subject. A quick rustle through the SQL Server Administration books convinced them that few others did either. The whole subject of tokens seemed to be completely neglected in many of the books on SQL Server Administration. After a long struggle, I think that the team succeeded well.

    Arthur Fuller is a stalwart ‘Friend of Red-Gate’ whose first article for us was over two years ago. The Database from Hell  is his fifth. This was supposed to be the first draft, but we liked its freshness so much we popped it in without the usual tidying and editing. We apologise in advance to the irate Scotsman who dislikes it when a Red-Gate product get a mention, but it was all part of the story. The illustration we used was adapted from Eric Liberge’s ‘Tonnere Rampant’, with Eric’s permission, and we are delighted with it. He is a great illustrator, whose work deserves to be more widely known.

    The Simple-Talk newsletter continues to demand more attention than it should, because it seems to be unreasonably singled out by some versions of Microsoft Outlook as spam. Conspiracy theorists might have a field day with this, but it is very likely an over-zealous algorithm. We’ll be experimenting with the layout in the next few weeks and any opinions you have will be gratefully received.

  • Thick and Fast

    Posted Thursday, February 07, 2008 7:37 AM | 0 Comments

    There is a great deal of activity on the Red-Gate forums at the moment. In fact, they are a fascinating read. Often, the threads take off in ways that nobody can really predict. My particular pleasure is in reading the 'off the cuff' remarks such as 'I have servers in NYC, Los Angeles, Pakistan, and India.' or 'I imported roughly 200 servers with over a thousand databases. The servers are distributed throughout the mid-West', or 'The number of servers I will be supporting is jumping to over 200 in the next few months' that give a glimpse of life at the DBA coal-face.

    One of the best, if you haven't looked, is the thread that started off on the Refactor Forum. Andras asked 'We support nearly forty options to customize laying out SQL, but is it enough?'. There were 41 responses, and the resulting thread was wildly popular. There are so many different ways of formatting SQL and there seemed to be an advocate for every one.

    Here is a subject where programmers will argue for hours. For example, although I agree with the great Joe Celco (SQL Programming Style 2005) about putting reserved words in Upper Case, we had people wanting everything in lower case. You're never going to please everybody, especially not Joe. 

    So, is there going to be a version that includes all the different layouts? Mike O'Neil wasn't the only one wanting to know. I'm a great fan of Refactor, but I've never quite tweaked the layout exactly how I want. Wthere wasn't great encouragement about a new version despite the interest in formatting. The roadmap only goes to the end of Q1 of this year so lets' hope Q2 for a new version as this is the Red-Gate tool I rely on the most.

    There is hope, though as SQL Prompt 3.8 will hopefully be available at the end of Q1. The Pro version evidently incorporates the Layout SQL functionality from SQL Refactor. It is an interesting move, since a lot of people aren't quite sure of the difference between the two products. and one wonders if the new Pro version will prove to be the logical line of development for the products

    SQL Prompt 3.7 patch release came out quietly, but the product is improving the whole time. I very quickly learned to set 'triggering' to manual (Cntl+Spacebar) when using SQL Prompt, and find it very handy as it cuts down on the need to keep accessing the Object Browser.  

    The SQL Data compare forum had a wonderful thread where people were asking for enhancements to the product and Richard kept bobbing up and explaining that they were there already. For me it was rivetting to hear of extreme problems encountered by users such as 'tons of tables with no indexes'.

    Over on the Alpha/Beta forums, the buzz around the Data Generator is dying down now as the developers start to assimilate all the feedback, and code the good ideas into the next beta. Now it is the turn of Dan and the SQL Response Beta.

    As I write this, it is early days, and I suspect that there will be a huge diversity of opinion on the things that should be monitored in SQL Server to give it a health-check. In the pub, it is always a debate that ends in flushed faces and Beer-glasses getting thrown.

    The Red-Gate site now has Blogs. I must admit that I had slightly mixed feelings about this, probably because someone tried to copy the existing blogs across from Simple-Talk and all the comments dropped off like autumn leaves, causing much confusion. However, Neil rallied round and started cross-posting from his wonderful blog on BusinessOfSoftware, However, the true purpose of the Red-Gate Blogs was illustrated best by David Connell in How to write a Generator for SQL Data Generator 1.0 Beta, whereas over here, Lionel showed how well a Red-Gate developer could blog on Simple-Talk with his SQL Puzzle 9


















<August 2008>
SuMoTuWeThFrSa
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456
Go With the Flow
 Knowing enough about the routes that messages take is vital to being an effective Exchange admin,... Read more...

When Email Collaboration Could Have Changed History
 In our mission to make history relevant to the busy IT executive, we speculate how Email might have... Read more...

Bunnikins!
 When an IT manager is selected as a victim of office politics of a large corporate, it is time for him... Read more...

Exchange Database Technologies
 One of the most misunderstood technologies in Exchange Server, regardless of its version, is the... Read more...

Top Tips for Exchange Admins
 Michael Francis hands out imaginary Olympic medals to the winner of the August 'Top Tips for Exchange... Read more...