MSXML: Access is denied - 80070005 - MSXML4.dll

Filed under: VBScript — Written by Chrissy on Monday, December 29th, 2008 @ 5:23 pm

Recently, I wanted to see if my ex in DC was reading my blog so I ran my referer log against an outdated copy of the MaxMind GeoIP locator database. I figured the database could use some updating so I ran the ImportMaxMindGeoIP.vbs script I posted awhile back, and much like in real life, I received an "Access Denied" error.

Line 63 was basically a simple line that stated: objXMLHTTPindex.Send() Most of the access denied errors on the net referred to POSTing unencrypted data but the script was performing a GET. After about a half hour of troubleshooting, I realized that the URL my script was pointing to was returning an HTTP code of "301: Moved Permanently."

Once I plugged in the new updated URL, the script worked without a problem. So if you're receiving a similar error, be sure to check that the URL hasn't been moved. You can do this by using Sam Spade, Firefox Extensions or just loading up the URL in your browser and seeing if it's redirected to a new location.

As for knowing if the ex is reading my blog, the results were inconclusive. I guess I'll find out soon enough. I mean, I could just ask her, but what's the fun in that? ;)

SQL Server: Creating a User-Defined Data Type from Scratch

Filed under: SQL Server — Written by Chrissy on Tuesday, December 16th, 2008 @ 6:36 am

I've always been slightly jealous of PostgreSQL's network data types, speficially, it's IPv4-supporting cidr type. I wondered if Microsoft would ever implement a similar type (I'm still wondering) but until they do, I'll work with the ghetto I've got: User-Defined Datatypes, which were introduced in SQL Server 2005.

Here's how to create a UDDs in three easy steps:

  • Create a new data type based on a native type.
  • Create a new rule.
  • Bind the new rule to the new data type.

Below, I willl use these 3 easy steps to create a simple ipv4 data type. First, I need to figure out which native type to build upon. Based a standard IPv4 address (herein ipaddr/IP address/IPs), IPs have a max of 15 characters (255.255.255.255) so I'll go with varchar(15) as the desired native data type for the new data type, "ipv4."

EXEC sp_addtype ipv4, 'VARCHAR(15)', 'NULL'

Next, a rule must be created. I'm not going to get super picky here to include subnets and what not, so I'll just write a rule that
1. Checks to see if the value has 3 dots/periods.
2. Checks to see if the IP address is valid by getting its numerical value and...
3. Ensures the numerical value is not greater than 4294967295 (the numerical value for "255.255.255.255")

CREATE RULE IPv4Format AS
((LEN(@strIP)-LEN(REPLACE(@strIP,'.','')))/LEN('.') = 3)   -- if there 3 periods  
AND (16777216 * CAST(PARSENAME(@strIP,4) as bigint) + 65536 * PARSENAME(@strIP,3) + 256 * PARSENAME(@strIP,2) + PARSENAME(@strIP,1)) < 4294967296
GO

Next, the rule must be applied:

EXEC sp_bindrule 'IPv4Format', 'ipv4'

Now that I have a new data type called "ipv4" I'm going to try it out :D First, I'll create a table named "iptest" with a single column named "ipaddr" that has a ipv4 data type. Then I'll try to insert some valid and invalid data.

CREATE TABLE iptest (ipaddr ipv4)
GO
 
INSERT INTO iptest (ipaddr) VALUES ('4.2.2.2')
INSERT INTO iptest (ipaddr) VALUES ('255.255.255.255')
INSERT INTO iptest (ipaddr) VALUES ('255.255.255.256')
INSERT INTO iptest (ipaddr) VALUES ('random text')
GO

The following results were returned, as expected:

(1 row(s) affected)
(1 row(s) affected)
Msg 513, Level 16, State 0, Line 4
A column insert or update conflicts with a rule imposed by a previous CREATE RULE statement. The statement was terminated. The conflict occurred in database 'AdventureWorks', table 'dbo.test', column 'ipaddr'.

The statement has been terminated.
Msg 513, Level 16, State 0, Line 5
A column insert or update conflicts with a rule imposed by a previous CREATE RULE statement. The statement was terminated. The conflict occurred in database 'AdventureWorks', table 'dbo.test', column 'ipaddr'.

The statement has been terminated.

Excellent! And there's how to create a somewhat useful UDD in a couple easy steps. If you want to just copy and paste the code in its entirety, click here to get all the SQL listed in plain-text format. Thanks to Burleson Consulting for the posting the CREATE RULE that gave me hope.

A Case of the Haves: Should I Get My Degree and/or Microsoft Certification?

Filed under: Tech Stuff — Written by Chrissy on Tuesday, December 16th, 2008 @ 12:45 am

OK, I realize this is my fifth blog post in two days after a seven month blog posting deficit. Is it obvious I'm procrastinating? Well, I am, but writing blog entries is way easier than studying. Apparently, my brain is fed up with learning what Microsoft recommends I do with SQL Server 2005. So until it decides to cooperate, I'll just write about SQL Server, or related topics thereof.

So.. on September 1, 2001 I just submitted my resignation to the CEO at Trellion Technologies because I no longer felt challenged and thought it was time for me to move on. The dotcom was still sorta going on and numerous calls from Microsoft recruiters left me confident I'd be able to immediately find a job or contract. Then September 11th happened.

For months, my phone didn't ring. My resume was out there on Monster and the jobs were there (sorta) but nobody seemed to need a 2 year DBA with no degree and no certifications. I didn't want to just sit on my hands so I started self-studying for the MCDBA in late October. I studied a ton and fortunately, I learned a whole lot. My study time in Tahoe was especially nice; I'd snowboard during the day and study for my certification at the coffee house at night. I felt totally West Coast.

I finished my MCDBA sometime in early January 2002 and updated my resume on Monster and around the web. The calls started coming in immediately. Within three weeks, I had two job offers. One of which was from Luce Forward, my very amazing employer whom I'm so fortunate to still be with, ~7 years and one cross-country relocation later.

             

I found what I learned while studying immediately useful both on my side projects and at Luce. Remembering this, I've worked to obtain my BS in Information Systems and upgrade my MCDBA to an MCITP-DBA, even though my employer did not request I do so. I love the challenge of getting certified and I appreciate how much I learn while studying. Just recently, I finished up the SQL Server 2005 Administrator's Pocket Consultant and oddly enough (or not), I thoroughly enjoyed almost the entire book! Wrox's Professional SQL Server 2005 Administration is also pretty good, as well as the Microsoft Press Training Kit for exam 70-431. Those books, coupled with nearly 10 years of experience as a DBA, helped me pass my first SQL Server 2005 exam with relative ease.

I'm currently studying for the last two of the SQL Server 2005 certs and hope I find the next exams as easy as I did the first.

So to answer the question posed in the subject of this post, I recommend getting a college degree to everyone and I recommend obtaining certifications to techies aiming to work for Corporate America. Geeks who specialize in working for or creating start-ups (like many of my friends in Silicon Valley) probably won't benefit much from certifications, but I do believe they will benefit greatly from CS and CE degrees, and to a lesser extent, IS degrees. But that's just my two cents. For reasons deeper than "it works for me," check out these posts from other bloggers about this topic.

The Simple-Talk Cookbook: A Cookbook for Geeks by Geeks

Filed under: Tech Stuff — Written by Chrissy on Monday, December 15th, 2008 @ 4:42 pm

I can't believe I forgot about this! I blame it on my crazy school schedule back in the day. In December of 2006, I was asked to contribute a recipe to the Simple-Talk Cookbook. Of course, I gladly obliged. The editor, Claire Brooking, published the very professional-looking cookbook to the opinion section of simple-talk. where she stated:

With over ten contributing chefs, all MVPs and experts from the SQL Server and .NET community, the cookbook is written by geeks for geeks. To get cooking, simply download the cookbook by clicking on the zip file in the top right-hand corner of this article or on the link below.

Happy cooking from the editorial team at Simple-Talk and all the starring chefs!

I won't lie, it made me feel great being addressed as an "expert" in my community. Thank you, simple-talk! Sorry for saying Phil Factor's anonymity kinda freaked me out ;)

Anyway, to download the cookbook which has my recipe titled "Chrissy's Favorite Bread Pudding," visit the article on on simple-talk.com. Alternatively, you can see the recipe here on RealCajunRecipes.com, or buy our Real Cajun Cookbook for yourself or a friend :D

SQL Server: Free Yet Noteworthy E-book Package from Red Gate Software/Simple-talk.com

Filed under: SQL Server — Written by Chrissy on Monday, December 15th, 2008 @ 4:04 pm

Before I start, I thought I would mention that I've always thought there was something a little suspicious about simple-talk.com. I couldn't quite put my finger on it, but.. ok for instance, one of their bloggers, "Phil Factor" (FILLFACTOR -- get it?), kinda freaks me out. Maybe it's his avatar.


Or maybe it's because he is so very anonymous. With that kind of talent, why on earth is he hiding his identity? Also, I also don't understand where all of these tremendously talented SQL pros came from and why simple-talk isn't super well-known. And how on earth did they score such influential authors as Joe Celko or even Louis Davidson?

So I'm poking around the the site for articles by DBA wiz Brad McGehee and I realize why the company seems so strange to me.... They are British! See, while I can appreciate British music (most of my library is filled with BBC Radio 1 artists), I've never been able to "get" other things they like, like British Humor. Ab fab? Not funny. Bland food? Not delicious. Powerless Monarchy? Not even grammatically correct.

But jokes about the British aside, simple-talk articles are bloody informative and well-written. Brad McGehee's posts and e-books about SQL Server are no exception. Here are a couple of my favs, along with a bonus from Louis Davidson.

  • BEST DBA CHECKLIST EVER
    The title says it all. Also available in PDF format if you want to professionally print a pretty poster.
  • A zipped collection of exceptional DBA e-books
    I didn't want to link directly to the 14MB zip, but to get just the e-book collection and not the software+e-book, click "Just the e-book please" link. This collection includes:

    • Brad's Sure Guide to SQL Server 2008
      This Top 10 list of New Features for DBAs somehow manages to weigh in at 113 pages of awesome.
    • How to Become an Exceptional DBA
      This e-book sports about 80 pages of exceptional advice for DBAs. With chapters dedicated to managing your Online Brand as well as Managing Your Brand within Your Organization, this book also includes advice for techs who aren't DBA. Topics covered include honing your people & communication skills, time management, education and the GOYA principle.
    • DBA Best Practices
      PDF version of "THE BEST DBA CHECKLIST EVER" mentioned above.
    • Pro SQL Server 2005 High Availability
      Oh whoa, this is the ENTIRE 775 page book by Allan Hirt/Apress.
  • Ten Common Database Design Mistakes
    Written by Louis Davidson, the person who wrote the APress book "Pro SQL Server 2005 Database Design and Optimization.

And in celebration of passing my first MCITP exam (70-431 - SQL Server 2005 Implementation and Maintenance) last Wednesday, here's a link to McGehee's article "Professional Certifications for DBAs."

iTunes Alternative: Songbird is to iTunes What Firefox is to IE

Filed under: General — Written by Chrissy on Monday, December 15th, 2008 @ 2:35 am

When I first moved back to Louisiana, I bought a car that fulfilled a few of my childhood dreams. It's an Audi A4 2.0T with rims, tint, sport suspension, BOOM and a Pioneer touch-screen iPod-compatible/GPS-enabled stereo system. I'm such a teenage kid. Haha. Anyway, what's even better is that I'm able to have a dedicated "iPod" for my car at no cost because I was able to recycle my friend's broken iPhone. After she dropped her iPhone in a drink at the bar and broke the touch screen, she got a Blackberry Curve and gave me her iPhone. I didn't need to use the screen (my stereo navigates through it via it's interface), so I was able to just wipe all of her data and load the disabled phone with my tunes.

It was at this time that I began to use iTunes extensively. Its speed was decent initially, but just recently, as my library grew, the load up time became unbearable. I didn't think I could find an alternative, however, because I didn't want to give up my iTunes store access and I figured all other media managers would be incompatible. So I was even looking for love when I found Songbird via a blog posting on audiojungle.net.

The first thing that caught my attention was Songbird's tabbed browsing. Then the add-ons. Then the mega-integration with one of my favorite sites, last.fm, which pretty much sold me on trying it.

During the install, I learned that Songbird stays in sync with my iTunes library/playlists so I can continue using iTunes when necessary (such as when I want to buy an album, though recently, I began buying more from Amazon MP3 [which my genius friend Ross helped to build :D]). Once Songbird was up and running, I went load up on some add-ons. There's quite a few, some useful and some not so much. Here are the ones I used to pimp my Songbird:

  • LyricMaster
    One of my favorite features! Songbird automatically gets Lyrics and displays them, plain text, in a selected pane.
  • iPod Support and Last.fm Scrobbling
    Kinda boring but totally important.
  • Song Notifier
    Pops up the name/artist of song near the system tray.
  • Concerts (by Songkick.com)
    Ohhh, this would have been more useful when I lived in San Francisco. Takes the artists in your library and let's you know where they are playing in a given city or region. Apparently, not a lot of my favorites are playing in New Orleans/Baton Rouge or Lafayette anytime soon.
  • Last.fm Album Art
    Awesome! Although I wish there was an option to just have last.fm's album art fill in the gaps and show the file's picture if there's one embedded.
  • Music Recommendations
    Powered by Last.fm. Love the Dykeenies? You might like Little Man Tate, too (I totally do!)
  • MinimizeToTray Revived (MinTrayR)
    This helps fill in the gap for one of the features I miss most in iTunes -- its built-in Windows Toolbar. But I can't have that right now, so at least I can minimize to tray and have Song Notifier tell me what's playing.

  • Click to see the prodigiousness up close.

    Songbird 1.0 is totally my favorite app of 08. If you haven't tried it yet and you are iffy about your current media manager, I suggest giving it a shot. It works on Windows, Mac and Linux.

    MS Defender Error: "Mallware Signeture Download" Appears Legitimate (Unfortunately).

    Filed under: Security — Written by Chrissy on Sunday, December 14th, 2008 @ 1:50 am

    Ow, the other day I was infected by the the Vundo trojan. I believe the trojan came in through an infected webpage and attacked a Java vulnerability on my machine. During the cleanup, I installed a variety of anti-malware software, including Microsoft Windows Defender. Although I don't believe things can be 100% clean after such an infection, I *really* don't want to reformat that workstation. That said, I was extremely suspicious today when a Dr. Watson/Microsoft Error Reporting error pops up with obvious misspellings (picture taken after report submission):



    "Mallware Signeture Download"

    I immediately went to Google and found that other people experienced the error and were also suspicious of the spelling errors, since such errors are common in actual malware. Feeling adventurous, I decided to allow the software to send the reports that I didn't bother looking at because if it's malware, it would be a setup anyway, right? Immediately after the data submission, I brought up a command window and typed netstat -b which listed the following:

    Active Connections
     
      Proto  Local Address          Foreign Address        State           PID
      TCP    MYWORKSTATION:1332       watson.microsoft.com:http  ESTABLISHED     2728
      [DW20.EXE]

    After going to http://watson.microsoft.com and receiving a Directory Listing Denied error, I pinged watson.microsoft.com and noted the IP resolved to 65.55.22.252. Using Sam Spade, I then asked ARIN who owns that IP block and sure enough, the IP is owned by Microsoft.

    12/14/08 15:35:18 IP block 65.55.22.252
    Trying 65.55.22.252 at ARIN
    Trying 65.55.22 at ARIN
     
    OrgName:    Microsoft Corp
    OrgID:      MSFT
    Address:    One Microsoft Way
    City:       Redmond
    StateProv:  WA
    PostalCode: 98052
    Country:    US
     
    NetRange:   65.52.0.0 - 65.55.255.255

    Now, I was pretty confident that the pop-up was indeed legitimate. But I became completely convinced after I found a posting by "Dude" on pcreview.co.uk that shows the string can be found within the program files, themselves.

    $ cd "$PROGRAMFILES/Windows Defender"
    $ for file in *; do strings -t x -e l $file | grep Mallware | grep Signeture
    && echo $file ; done
    10cdc Mallware Signeture Download
    MSASCui.exe
    26fc Mallware Signeture Download
    MpSigDwn.dll

    Having such spelling errors in an anti-virus program is unacceptable. Hopefully Microsoft will address it soon so that IT pros can stop wasting their time researching its legitimacy. However, seeing that the problem has been around since at least 11/2006, a fix doesn't really seem likely.

    T-SQL: Find Duplicates Without Using JOIN

    Filed under: SQL Server — Written by Chrissy on Thursday, May 15th, 2008 @ 12:34 pm

    I'd forgotten about this lil trick.

    select eUserName from eAttribute GROUP BY eUserName  HAVING COUNT( eUserName) > 1

    SQL Server: Change the Owner of All Tables to "dbo"

    Filed under: SQL Server — Written by Chrissy on Wednesday, May 7th, 2008 @ 6:32 pm

    Reference for me. Reference for you.

    sp_MSforeachtable @command1="EXEC sp_changeobjectowner '?','dbo'"

    VBScript: Clean Up Imported SIM Card Contacts in Outlook

    Filed under: VBScript — Written by Chrissy on Friday, April 11th, 2008 @ 2:11 pm

    The other day, I was texting a friend and some guy looked at me and said "Oh hey, 2002 called, it wants its T9 back." Haha, slightly cliche but I laughed anyway. Then I went and bought myself a Blackberry.

    I totally love it, I won't lie. So I imported my contacts into Outlook from a Sony Ericsson mobile phone and they came out kinda chu-chu. All the contacts came in as "Work" numbers and were all prefixed by ";\M". I cleaned the M's out manually but then wrote a script to list all the numbers as Mobile numbers. For consistency's sake, I also cleaned up all of the numbers themselves to just be, for instance, 2345551212. Here's the script in case you would like to do a mass cleanse as well.

    Set objOutlook = CreateObject("Outlook.Application")
    Set objNamespace = objOutlook.GetNamespace("MAPI")
     
    Set colContacts = objNamespace.GetDefaultFolder(10).Items ' 10 = olFolderContacts
     
    For Each objContact In colContacts
      if len(objContact.MobileTelephoneNumber) = 0 then
        objContact.MobileTelephoneNumber = objContact.BusinessTelephoneNumber
        objContact.BusinessTelephoneNumber = ""
        'Wscript.Echo objContact.FullName, objContact.BusinessTelephoneNumber, objContact.MobileTelephoneNumber
        objContact.Save
      end if
      
      if len(objContact.MobileTelephoneNumber) > 0 then
        mobileNumber = objContact.MobileTelephoneNumber
        mobileNumber = replace(mobileNumber," ","")
        mobileNumber = replace(mobileNumber,"-","")
        mobileNumber = replace(mobileNumber,"(","")
        mobileNumber = replace(mobileNumber,")","")
        mobileNumber = replace(mobileNumber,"+1","")
        
        if left(mobileNumber,1) = "1" then mobileNumber = right(mobileNumber,len(mobileNumber)-1)
        objContact.MobileTelephoneNumber = mobileNumber
        objContact.Save
      End if
      
    Next

    Ouu my grammar has gone downhill since I spent a weekend in Louisiana.