dirq.net

the life and work of dirk watkins

April 18, 2013
by Dirk Watkins
0 comments

How to Run SQL Server Management Studio as a Different Windows User

If you’re using Windows Authentication for your SQL Server database you’ll need to run SQL Server Management Studio (SSMS) as that Windows account to test queries.  SSMS normally runs as the user logged in to Windows, but there is a simple way to run it as the database access account.

Just shift-right-click on a shortcut and select “Run as a different user“.  (Windows 7)

Shift-Right-Click a shortcut to run the program as a different Windows User.

Shift-Right-Click a shortcut to run the program as a different Windows User. (Windows 7)

You’ll be presented with a Windows login prompt.  Log in and SSMS will open.  Note that the connection dialog has the new user in the Windows Authentication area

Connect to Server Dialog

Connect to Server Dialog

Note: You’re now running the program as a different user, so it probably won’t have access to the files you normally use.  My fix was to give the account read/write to the folder where I hold my SQL scripts.

This tip will work for other programs too.  Let me know how you used it in the comments below.

April 10, 2013
by Dirk Watkins
0 comments

Turn Yeast into a Mosquito Killing Army!

Mosquitoes are drawn to CO2.  Yeast create CO2.  So, use yeast to draw mosquitoes into a trap.

I heard about this tip somewhere and thought I’d share it with you.  It cleverly uses yeast’s carbon-dioxide bi-product to trick mosquitoes into going into a bottle.  Since mosquitoes are also drawn to heat, you can paint the bottle black to make it extra temping.  This is a very natural and eco-friendly pest control.  You can just use some old bread yeast, although some spent beer-brewing trub (pronounced TROOBE) will work awesomely too.

Mosquitos Trapped in a 2-Liter Bottle

Items needed

  • 1 2-liter soda bottle
  • scissers
  • 1 cup of water
  • 1/4 cup of sugar (white or brown)
  • 1 teaspoon of yeast

Steps

  1. Cut the plastic bottle in half.
  2. Mix sugar with hot tap water. When cool, pour in the bottom half of the bottle.
  3. Add the yeast when the water is cool. No need to mix. Yeast eat sugar, and then creates carbon dioxide which attracts mosquitoes.
  4. Place the funnel part, upside down, into the other half of the bottle.  You can tape them if you want.
  5. (optional) Paint the bottle, or wrap it with something black, leaving the top uncovered.  The black will absorb more heat during the day.  Both the yeast and mosquitoes like it warm.
  6. Place the trap along the edges of your yard.

Maintenance (Every Few Weeks)

Add some more cooled sugar water every 2 weeks so the yeast has something to eat.  If there are a lot of dead mosquitoes, and or the liquid looks especially nasty, spray it out and start over.

April 2, 2013
by Dirk Watkins
0 comments

Quickly See a Table’s Columns in SSMS

When looking at long queries you’ll typically need to remember what data is in one of the tables.  SSMS allows the creation of shortcut keys that can be used to quickly look at the first row in a table.  You’ll then be able to see the column names and some example data.

In SQL Server Management Studio (2012 shown), create a new shortcut key by going to:

Tools > Options > Environment > Keyboard > Query Shortcuts

Add the beginning of a query to the shortcut key you like, later on you’ll see how the table name will be appended when the query is run.

SSMS Query Shortcuts

“SELECT TOP 1 * FROM”

After you click ok on the dialog, and create a new query window, you’ll be able to select a table name in a query and use your shortcut key.  The selection in the query analyzer will be appended to your shortcut query and run.

Select the full table name and press your new shortcut key.

Select the full table name and press your new shortcut key.

The screenshots are from SQL Server Management Studio 2012, but older versions have the shortcut key option too.  I bet it even works in the old Query Analyzer.

Cool eh?  Maybe you like to get the top 200 rows to get a better picture of the table’s data?  I’m sure you’ll have tons of ideas on cool shortcuts you can run.  Be nice and leave me some ideas in the comments.

Shift + Right Click

January 23, 2013
by Dirk Watkins
0 comments

Open a CMD Window From Anywhere!

In Windows 7, hold down shift and right click a folder to see some additional menu items.  You’ll notice a few extra options like “Open command window here” and “Copy as path”.

Shift + Right Click

Shift + Right Click

Open command window here

Often when browsing folders in Windows Explorer you will want to open a command shell, using the directory being viewed as the current directory:

cmd.exe opened to the selected folder

cmd.exe opened to the selected folder

Then you can do all sorts of cool things, like list out all the files in the directory using dir.

List a folder contents using DIR

List a folder contents using DIR

Copy as path

The “copy as path” option is also really handy on files, especially when uploading files to websites.  Now you can browse to an upload form, hit browse, and just paste in your copied path.

Copy as path, then paste into an upload form

Copy as path, then paste into an upload form

 

November 20, 2012
by Dirk Watkins
1 Comment

Remove Windows Authentication Prompts in Firefox

If you have intranet sites using Windows Auth that are not fully qualified domain names (fqdn) (like http://companyintranet/) you probably noticed that Firefox constantly prompts your users to enter their windows authentication credentials.  You can easily get Firefox to work like IE by allowing automatic logins.

  1. Go to “about:config”
  2. Filter the keys down to “network.automatic”
  3. Edit network.automatic-ntlm-auth.allow-non-fqdn value to true

network.automatic-ntlm-auth.allow-non-fqdn