Author: joe

SQL Basic Command Syntax

I use SQL statements on an almost daily basis, yet I have trouble remembering the syntax of even the most basic commands.  Thus I decided to post a cheat sheet here for quick and easy reference.  I hope you may find it valuable.
Selecting Records SELECT * FROM Table WHERE Param1 < 10 ORDER BY Param2
Selecting Records Into a New Table SELECT * INTO newdb.dbo.newtable FROM olddb.dbo.oldtable
Updating Records UPDATE Table SET Param1 = ‘cat’, Param3 = ‘fish’ WHERE Param2 = ‘dog’
Adding Records INSERT INTO Table (Param1, Param2) VALUES (‘xx’, ‘yy’)
Deleting Records DELETE FROM Table WHERE Param1 = ‘value’
Group By SELECT column_name, aggregate_function(column_name) FROM table_name WHERE column_name = value GROUP BY column_name
List all tables & views in database SELECT TABLE_TYPE, TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES ORDER BY TABLE_TYPE, TABLE_NAME

SQL Studio: Clear Server List

Over time, SQL Server Management Studio’s Server Dropdown box gets cluttered with many servers.  Quite often some of the servers no longer exist.  However, SQL Studio does not give the user an option for clearing this list.  I found this to be very frustrating.  The instructions below show how this can be done.

I tested these instructions with SQL Studion 2008 running on Windows XP and Windows 7.

SQL Server 2008 running on Windows XP:

  1. Close SQL Studio if it is open
  2. Go to C:\Documents and Settings\Application Data\Microsoft\Microsoft SQL Server\100\Tools\Shell
  3. Delete the file SqlStudio.bin
    The file will be recreated automatically when SQL Studio starts.

SQL Server 2008 running on Windows 7:

  1. Close SQL Studio if it is open
  2. Go to C:\Users\AppData\Roaming\Microsoft\Microsoft SQL Server\100\Tools
  3. Delete the file SqlStudio.bin
    The file will be recreated automatically when SQL Studio starts.

Special thanks to Dave Pinal at http://www.SQLAuthority.com for providing this information.

How to fix Schedule Missed error on WordPress posts

If you are experiencing then problem “scheduled missed” when scheduling a post in WordPress, I found the solution on http://blog.5ubliminal.com/.  Simply do the following:

  1. Copy the code shown below and save it as scheduled-mias.php.
  2. Upload the file to wp-content/plugins on your WordPress site
  3. From your dashboard, enable the plugin named Scheduled Mias

That’s all there is to it.


<?php

/*

Plugin Name: [Post] Scheduled MIA-s

Plugin URI: http://blog.5ubliminal.com/topics/wordpress/plugins/

Description: Bring the left-for-dead <code>Missed Schedule</code> (MIA) posts back to life.

Version: 5.U.B

Author: 5ubliminal

Author URI: http://blog.5ubliminal.com/

Support URI: http://blog.5ubliminal.com/support/

*/

// —————————————————————————– //

define(‘SCHEDULEDMIAS_DELAY’, 15); // Minutes .. change as you wish

define(‘SCHEDULEDMIAS_TRANSIENT’, ‘scheduled_mias’); // Minutes .. change as you wish

// —————————————————————————– //

class Schedules_MIAs{

public function Schedules_MIAs(){ $this->__construct(); }

public function __construct(){

add_action(‘init’, array($this, ‘onInit’), 1);

}

public function onInit(){

// I disable internal cron jobs for post publishing completely

// … Comment the line below to let WordPress try do its job before we kick in

remove_action(‘publish_future_post’, ‘check_and_publish_future_post’);

if(get_transient(SCHEDULEDMIAS_TRANSIENT)) return; // Make sure enough time elapsed since last run

set_transient(SCHEDULEDMIAS_TRANSIENT, 1, abs(intval(SCHEDULEDMIAS_DELAY)) * 60); // Reset delay

global $wpdb; // Global $wpdb object

// Find MIA post_IDs, try both LOCAL datetime and GMT datetime

$scheduledIDs = $wpdb->get_col(

“SELECT `ID` FROM `{$wpdb->posts}` “.

“WHERE ( “.

” ((`post_date` > 0 )&& (`post_date` <= CURRENT_TIMESTAMP())) OR “.

” ((`post_date_gmt` > 0) && (`post_date_gmt` <= UTC_TIMESTAMP())) “.

“) AND `post_status` = ‘future'”

);

if(!count($scheduledIDs)) return; // None found … bail

foreach($scheduledIDs as $scheduledID){

if(!$scheduledID) continue; // Just in case

// Publish each post_ID the WordPress friendly way

wp_publish_post($scheduledID);

}

}

};

// —————————————————————————– //

$Schedules_MIAs = new Schedules_MIAs();

// —————————————————————————– //

?>

Where Is the Startup Folder?

I was recently searching for the startup folder for the User profile and the All Users profile in Windows 7. Systems administrators frequently create scripts which must run at login. Sometimes the scripts target an individual user profile and other times they target the computer in general regardless of the user.

In Windows XP, the startup folder existed in the following locations:

User Profile
 C:\Documents and Settings\Start Menu\Programs\Startup

All Users Profile
 C:\Documents and Settings\All Users\Start Menu\Programs\Startup

In Windows 7 however, access to the “Documents and Settings” folder is denied. This was the problem I ran into. I soon discovered that, in Windows 7, the startup folder was moved to the following locations:

Windows 7 User Profile
  C:\Users\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

Windows 7 All Users Profile
 C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup

Startup scripts are handled the same way in Windows 7 as they were in Windows XP. The difference is that the location of the startup folder has changed.

Office 2010 spell check does not work

Problem:

Spell check does not work in Office 2010.  Intellisense does not detect incorrectly spelled words and manually running spell check does not work either.

Solution:

  1. Click on Office Button | Word Options | Add-Ins | Manage: Disabled Items. If you see any disabled items that relate to spelling, try enabling them.
  2. If the previous suggestion doesn’t help, then:
    a. Close Word and any other open applications.
    b. Click on Start | Run | Open and type “regedit” (without the quotation marks).
    c. If the following key exists, delete it.
    HKEY_CURRENT_USER\Software\Microsoft\Shared Tools\Proofing Tools\1.0\Overrided.
    d. Exit the Registry Editor.
    e. Restart your computer.

NOTE TO SUPPORT STAFF:  The Windows 7 registry editor will prompt for an administrator password.  It will show the HKEY_CURRENT_USER tree for the user credentials provided.  Have the non-admin provide his or her credentials or you will not see the correct tree.

Pasted from <http://answers.microsoft.com/en-us/office/forum/office_2010-word/office-2010-spellcheck-is-not-working/df78d1af-1d42-4c7f-aed3-571997e6323d>