How to create a copy of a SQL table

Before clicking the button to execute an update or delete query on a table in Microsoft SQL Server Management Studio, have you ever asked yourself, Do I really want to do this? I know I have. This handy statement creates a copy of the table you specify so that you don’t lose all of your data if something goes awry.

SELECT *
INTO {%new table name%}
FROM {%existing table name%}

How to find scheduled task history on Windows Server 2003

I recently needed to look at the history for a particular scheduled task on a client’s Windows Server 2003 machine. In newer versions of Windows Server, this is easy: open Task Scheduler, select the appropriate task, and go to the History tab.

On Server 2003, this information is somewhat less obvious, but blogger Guarang Patel pointed me in the right direction with a post explaining how to find the task history. Essentially, after opening Scheduled Tasks, you go to the Advanced menu and choose View Log, and then you’re where you need to be.

The task history on Server 2003 is unfortunately very short indeed; in my case, I could only find two entries for the task I was researching because a different task is scheduled to run and gets written to the log far more frequently. Nevertheless, it’s helpful to know where to look.

How to prevent corrupt profile message in Cars video game on Windows 10

Playing old video games can be fun. Getting them working properly on newer hardware, however, is sometimes a challenge. In a prior entry, I explained how to run NASCAR Racing 1999 Edition on Windows 10. Today, I want to focus on THQ’s 2006 Cars game based on the Disney-Pixar film of the same name.

I recently installed Cars on my Windows 10 box and was able to launch the game with no problems. Beautiful scenery, just like in the movie, and still a great deal of fun. Everything looked like it was working perfectly.

The next time I went to play it, however, the game advised me that the profile I saved during my previous session was corrupted. Boo, I thought. It’s not as though I had made a lot of progress during my first session, but still.

To work around this problem, I right-clicked the Cars shortcut on my desktop and chose to troubleshoot compatibility, then chose to troubleshoot program. I checked the checkbox labeled The program requires additional permissions, then moved on to test the program.

I ran a race and saved my profile, then exited the program. In the compatibility troubleshooting window, I clicked Next, prompting Windows to save the settings. Since then, when I launch Cars, it loads my profile without any trouble, and I’m able to save my progress as I go along.

How to delete .cab files from Windows Temp folder and prevent them from regenerating

I recently noticed at work that my Windows 7 virtual machine’s C: drive was down to its last couple of gigabytes of free space. What’s up with that? I wondered. After doing a bit of poking around, I discovered that the Windows Temp folder was clogged with multiple .cab files, nearly 32 GB of them in this case. Not cool!

It seems that all of these files are related to Windows updates not installing correctly, or something along those lines. The solution given by Microsoft forum user 5kyFx is this:

  1. Delete the .log files from %systemroot%\Logs\CBS (which prevents the .cab files from being regenerated)
  2. Delete the .cab files from %temp% (which clears space on the drive)

In my case, this appears to have solved the problem.

How to compare two spreadsheets in Excel 2010 and earlier

I recently needed to compare the results of two spreadsheets to check for differences between them. Although newer versions of Microsoft Excel have this functionality baked in, I was using a computer with Excel 2010 installed.

Thankfully, Svetlana Cheusheva at AbleBits wrote a blog post earlier this year that explored the different options for this sort of task. The approach I took involves having both spreadsheets in a single workbook, then inserting this in a third spreadsheet:

=IF(Sheet1!A1<> Sheet2!A1, "Sheet1:"&Sheet1!A1&" vs Sheet2:"&Sheet2!A1, "")

You then copy that formula from cell A1 to all the other cells where, in the first two spreadsheets, there might be data.

Avoiding errors when running SQL update queries

When working on an update query, I prefer to run it first on a test database to make sure it does what I think it’s going to do—and to make sure I haven’t made a simple mistake. When that’s not possible, however, there is another approach that works pretty well, too: select, then update.

First, I run a query like this with the update portions commented out:

SELECT *
FROM customers
--UPDATE customers
--SET title = 'Mr.'
WHERE id > 123 and id < 150
ORDER BY id

After I’ve checked the results to ensure I’ll be affecting only the records I intend to change, I comment out the select, from, and order by bits, and uncomment the update and set lines:

--SELECT *
--FROM customers
UPDATE customers
SET title = 'Mr.'
WHERE id > 123 and id < 150
--ORDER BY id

By taking this approach, I’m less likely to accidentally update records I didn’t intend to touch.

Microsoft KB3177725 prevents some programs from printing multiple consecutive documents

I’ve been in the IT world long enough to know that not every Microsoft update brings only good things to the table. That was certainly the case when I recently encountered a real dud affecting one of my employer’s customers.

The summary for KB3177725 states, “This security update resolves vulnerabilities in Microsoft Windows.” Great! We like patching security holes. This update has a darker side, however, and although the patch description now mentions it as a known issue, that was not the case when the customer’s problem initially popped up.

The problem

I first became aware of the problem last month when the customer reported that he was unable to use a program created by my employer to encode more than one magnetic stripe card at a time on his Magicard card printer. If he tried sending a second job to the printer, the program indicated the job had been queued successfully, and it would even show up in his print spooler, but the card would not actually print even if the spooler was restarted. The only way to print another card was to close the encoder software, reopen it, and send the print job again.

Troubleshooting

Although the problem initially looked like it might be related to my employer’s software, nothing had changed on our end, but we still checked to make sure the customer had the latest version of the software and the latest driver for his card printer. Eventually, I headed to Control Panel to check out the list of recently installed Windows updates, one of which was the aforementioned KB317725. It was automatically installed around the same time the customer started having problems—an interesting coincidence—and a quick search revealed that it was causing printing problems for other people.

According to posts in that forum thread, the problem occurs in a given program only if it is coded a certain way, but such programs work just fine up to the point that the Microsoft patch is installed. You can read up on the details if you like, but it’s beyond the scope of what we’re discussing here.

The problem our customer was having was not exactly the same as what other people had experienced because he could print only one document before needing to restart the encoder software, whereas other people could print two in a row before running into trouble. Even now the known issues section of the patch description says, “After you apply this security update and you print multiple documents in succession, the first two documents may print successfully. However, the third and subsequent documents may not print.” Nevertheless, the patch being installed around the same time he started having trouble suggested to me that it was probably related.

The solution

By the time I ran across this issue, Microsoft had already been made aware of the problem. An update, KB3187022, was available, not through the usual Windows Update interface but through the Microsoft Update Catalog.

We downloaded this patch and installed it on the customer’s computer, and after a reboot, he was again able to print multiple cards in succession without needing to restart his encoder software between print jobs.

Summary

Since first encountering this problem, we’ve had a second customer using the same encoder software report the same problem, except in his case he was able to print two cards in a row before having to reboot the software. That situation exactly matched the problem described in the update’s known issues section.

We were lucky that the first customer was using a Windows 7 machine since, at the time the issue first cropped up, Microsoft had not released a patch for the Windows 10 version of the update, KB3176493. That has since changed, and a fix is now available for Microsoft’s latest OS, too.

Naturally, you can’t blame Microsoft for every problem that comes up, nor is every problem their fault. Nevertheless, when a problem pops up seemingly out of nowhere at the same time Windows updates are installed, I can’t help but take a second look.

Internet Explorer reset fixes Microsoft Edge, Skype connection problems

Last week, my Windows 10 work laptop started having issues. First I noticed that Microsoft Edge was unable to load any websites. Then it was Internet Explorer. Then Skype reported its homepage was unavailable. As you might imagine, this caused my antennae to go up in a hurry.

A reboot did not help, and neither did a suggestion I found from a Microsoft representative to run System File Checker (sfc.exe). I did that over the weekend, but it found no problems at all. That was nice, particularly considering that I’ve been using this machine for less than a month.

The solution to the problem in my case, at least, was simpler than I expected. I searched for the Internet Options item from the Control Panel, navigated to the Advanced tab, and clicked Reset. I checked the Delete personal settings checkbox—that may not have been necessary, but I figured I might as well burn it all—and clicked Reset, confirmed that I wanted a clean slate, and then rebooted again, and voila! Microsoft Edge, Internet Explorer, and Skype all went back to working as expected.

I find it interesting that something out of kilter in Internet Explorer could affect Edge and Skype, too. IE may officially be on the way out the door, but its tendrils are apparently still wrapped around some fairly important bits of the Windows operating system.

How to adjust the size of your Hyper-V virtual machine’s window

I recently started a new job, and due to the need to make VPN connections, I’ve been getting familiar with Hyper-V Manager. I’m using a laptop, so one of the first things I wondered was how I could fix the size of my virtual machine’s window so that I don’t have to do a lot of scrolling. Unlike with Remote Desktop Connection, where you can specify the size of the window before connecting, Hyper-V Manager did not appear to have such a configuration option.

It turns out the answer to my question is very simple: for a Windows 7 virtual machine, at least, all you have to do is change the screen resolution on the VM itself. To do that, right-click on the VM’s desktop and choose Screen Resolution (for Windows 7) or Display settings > Advanced display settings (for Windows 10) and choose a resolution small enough to fit on your physical computer’s display.

After you adjust your VM’s resolution, the window in which the VM is running resizes itself automatically, and you’re good to go.

SQL query for finding column in database

Last week, one of my coworkers was trying to figure out which tables in a database contained a particular column name. That’s something I’ve had to do in the past, and although I didn’t remember the exact details, a quick search turned up this gem from a Stack Overflow thread:

SELECT column_name, table_name FROM information_schema.columns WHERE column_name like '%{column name}%'

This query returns a list of all tables and views in the database that have column names containing the name for which you are searching.

If you know the exact name of the column, you can change the where clause to WHERE column_name = '{column name}'.