Monday 21 March 2011

Running Windows 2000 on Hyper-V

I recently tried to install a Windows 2000 VM for old times sake (well, for testing actually...).

If you attempt this, here's what to adhere to -
  1. Only configure 1 virtual processor
  2. Install SP4 (I had to use DoIso to get a downloaded SP4 inside to the VM)
  3. Install HyperV Integration services to the client VM 
  4. Enable networking in the VM (assign ip, subnet, gateway & dns)
  5. Run Windows Update (to get everything post SP4).
I had all kinds of fun before I settled on this order. An unpatched Windows 2000 installation comes with Internet Explorer 5. IE5 prevents connection to Windows Update and it's javascript handling prevents the download page for Service Pack 4 from functioning!

Mounting the host drive also proved problematic before SP4 was applied, with the Windows 2000 guest causing the host server to die with a BSOD.

Friday 18 March 2011

Audit Scripts : When were SQL Server & Windows Installed?

What version of SQL Server are we running ?

SELECT @@version

Microsoft SQL Server 2008 (SP1) - 10.0.2531.0 (X64) Mar 29 2009 10:11:52 Copyright (c) 1988-2008 Microsoft Corporation Enterprise Edition (64-bit) on Windows NT 6.0 (Build 6002: Service Pack 2) 
 
When was SQL Server installed ?

SELECT  createdate as InstallDate 
FROM    sys.syslogins 
where   sid = 0x010100000000000512000000 

When was Windows installed ?

Open a command prompt, and type -

systeminfo | find /i "install date"

Links :
How to check when SQL Server was installed
How to check when Windows was installed

Wednesday 16 March 2011

TSQL : Returning the SQL Server IP Address

I recently wrote some audit scripts and wanted to find the IP Address of the server from TSQL. The majority of the replies on twitter correlated with my google findings, i.e. to use extended stored procedure xp_cmdshell to run an operating system command.

Leaving security concerns aside , here's a reminder on enabling xp_cmdshell

Using xp_cmdshell to retrieve server ip address -

create table #cmdresults(ip varchar(255))
insert into #cmdresults exec xp_cmdshell'ipconfig | find "IP Address"'
select ltrim(rtrim(substring(ip,charindex(':',ip)+1,len(ip)))) from #cmdresults where ip is not null
drop table #cmdresults

On moving it to my server, I found it did not work. The difference being that I needed to look for 'IPv4 Address', not 'IP Address' on my Windows 2008 installs where entries for IPv4 and IPv6 could both exist.

A simpler version was suggested by Kendra Little (@Kendra_Little | blog) was to look at the connections dmv, like this

Using DMV to return session ip address -

SELECT local_net_address FROM sys.dm_exec_connections WHERE session_id=@@SPID 

This returns the connected client IP, so it only returns the server IP if you are working on your server (or an rdp session on it).

For the purpose of what I needed (reports emailed from the sql server), it is perfectly adequate (and tidier than xp_cmdshell).

Tuesday 8 March 2011

Finding Transactions / Second

The Performance Counters dmv can be used to determine Transactions per second.
Transactions is a cummulative counter however, so here is what I do to interpret it.

Use the script below, replacing 'database_name' as appropriate.
You may wish to change the delay (10s used here) to a more appropriate value (remembering to change the calculation that follows too).

SELECT cntr_value, *
FROM sys.dm_os_performance_counters
WHERE counter_name = 'transactions/sec'
AND OBJECT_NAME = 'SQLServer:Databases'
AND instance_name = 'database_name'
  
WAITFOR DELAY '00:00:10'
  
SELECT cntr_value, *
FROM sys.dm_os_performance_counters
WHERE counter_name = 'transactions/sec'
AND OBJECT_NAME = 'SQLServer:Databases'
AND instance_name = 'database_name'


The queries returned 581820652 and 581821012 respectively.

581821012 - 581820652 = 360

360 Transactions in a 10 second period

Therefore, 360 /10 = 36

36 Transactions per second.

Saturday 5 March 2011

Time Wasters - LinkedIn

LinkedIn is by far the easiest network to control and therefore I'm covering it out of completeness to the time wasting series (Groupon, Twitter & Facebook)

LinkedIn is the professional social tool. A marketing platform for your CV and a way to keep in contact with past colleagues. Being on it is a no brainer for job opportunities. With the appropriate security settings, it can link you to recruiters looking for the skills you possess. People you've worked with can see how you've progressed and potentially re-engage with you for their next project.

Like Facebook and twitter, managing LinkedIn is about reducing the noise, getting rid of irrelevant updates.

To do so -

Hide updates from busy users
This is incredibly easy, can be done with a single click.
There are 2 groups of people who I 'hide'
  1. Recruiters (a high number of updates)
  2. Those who connect LinkedIn to Twitter (a pet hate)
    The 2 platforms are very different and flooding my LinkedIn with twitter updates is annoying and adds no value 'professionally', especially if i'm following you on twitter too.
Review LinkedIn Group memberships
These are mostly created by recruiters fishing for leads. If you need to be in them, disallow the group from sending you email updates of activity.

Being mostly text based, my top tip for LinkedIn is to enable (and subscribe to) your network updates via a private RSS feed. Saves a lot of time and you see all the same information.

Friday 4 March 2011

Time Wasters - Facebook

Having evaluated the time wasting potential of Groupon and Twitter, I'm now looking at Facebook.

First off, I don't believe Facebook is a total waste of time. It's a valuable social tool that the majority have embraced in some form. It's availability on (and integration with) mobile devices is excellent (thus increasing it's addictiveness).

For the current generation it threatens to replace personal emails. People no longer have the hassle of having to keep an address book up to date. Users need no sit there blankly, seeking inspiration of what to type. It's all infront of you! Recent activities (in status updates and photos), tastes, opinions and interaction with others.

I've largely tamed my facebook account making visits a short, sweet experience.
Here is what I've done to achieve this.
I'm not going to list how, as a) those instructions would quickly become obselete and b) you can use your favourite search engine.

Making facebook managable is about reducing the amount of 'noise' in your updates, i.e,

Turn off email notifications of facebook events.
You'll see them when you log in anyway.

Block applications when you first see them.
Bob is playing Farmville will become a thing of the past.

Review the interests you have listed
Bands and television programs are the typical examples. Whilst these have revealed some surprising matches amongst my friends, they are mostly used to market to you.

Review the pages you have 'liked'.
That actress might have been hot in a series 2 years ago, but she has faded into obscurity now and updates on her activity are actually not interesting. Actually, having her in your 'likes' is most likely saying 'I'm a perv who likes this superhero chick in pvc'.

The same advice re; facebook 'likes' applies for products you once used (or entered a competition via). It's all marketing and has low informational value.

People
This is down to personal choice, but if someone is not important to you ask yourself what they are doing on your facebook!
If their updates are too frequent, uninteresting or blatantly rude, you have a couple of options -
  1. Unfriend them (sometimes en masse via a friend cull)
  2. Hide their updates via preferences.
The first is quite severe and will be quickly noticed as you disapear from their facebook. It also sends out quite a strong message without explanation.

Hiding updates is not difficult (and is less political). Those who bleat about having no money, their drunken antics or constantly post videos of their flea ridden mutt will disapear from your updates. You can still chose to check their profiles if you wish, or reverse the setting should you have a change of heart.

RSS private feeds can be used to see activity in your Facebook account. The feeds contain only status updates (i.e. text information) which limits their use. Surely the photos are the most entertaining part of the Facebook experience?  For me, RSS with Facebook is useful to gauge when it is worth 'logging in'.

Thursday 3 March 2011

Time Wasters - Twitter

Continuing my evaluation of the time I spend online, I'm looking at Twitter behaviour I hate..

First of all, I like Micro blog service Twitter. I originally did not see the point and viewed it as time wasting. As the SQL Server community grasped it however I soon saw the value. The #SQLHelp hash tag quickly enables people to ask and answer technical questions. At the SQLBits conferences, the #SQLBits tag allows you to share thoughts with other techies. It has also enables you to meet up with comrades and arrange which pub you're going into later.

Twitter can become a bit like an email account without a spam filter. You quickly have to wade through a lot of rubbish to get to the good stuff. It is mostly people's behaviour that causes this.

My gripes with Twitter, are -

Noise
I'm not a fan of the inane banter twitter can promote. Thats down to personal style, but you can quickly 'unfollow' inviduals whose updates you find too much. It doesnt stop other's retweeting those messages back into your feed however.

Spam
Mention key subject words (e.g. iphone) and you'll find yourself being 'followed' by marketeers trying to sell you the same, in the hope you will follow them (twitter etiquette or twitiquette if you like)

Self Promotion
Everyone links blog posts they have written personally. I don't have a problem with that (apart from the fact I'm already subscribed to RSS feeds for the SQL Digerati). The extent to which some do so however is quite overwhelming. The worst offenders have to be promoters of their 'Daily Paper' service Paper.li , which (IMHO) is a time wasting aggregation of things I've already read / have queued in Google Reader.

Retweets
The idea here is to rebroadcast someone else's message, widening it's audience. You may chose to do so if it is interesting, relevent or humourous (to you anyway!)
What i hate here is the blatant Arsekissing that I frequently see i.e. the same users retweeting the messages of their nemeses. Chances are I am following the forementioned nemesis myself and have already seen the message (I have).

Reliability
To be fair, I hardly ever see Twitter's Fail Whale anymore, but the network was far from resilient a year ago.

Wednesday 2 March 2011

Time Wasters - Groupon

As part of evaluating the time I spend online, I'm looking at some of the services I've joined. First up is Groupon...

Groupon is an email discount service that offers you the opportunity to buy 'daily deals'.
I suspect it's current lack of relevance to me comes down to Targeting.

It's Geographic targeting in the UK is poor. I am based in the county of Surrey which is a big place. Consequently, the deals I receive are not local. The majority infact are for London. the cost of travelling therefore outweighs money saved with a 'deal'

Relevance of the deals is poor. If Groupon allowed me to state my age, and sex then maybe I wouldn't receive offers for Facials , Pampering days and Bikini Line laser treatment!
(Thinking about it, maybe beauty treatment is not so badly targeted after all!)

To quote Matt Bagwell’s blog

I’m returning to work. But I have shut down my Groupon account. That’s 730 less emails a year and I don’t need that much teeth whitening or meal discounts.

To give you an idea –


 Sorry Groupon, I'm sure you'll get there. Right now, my only option is to unsubscribe...

Tuesday 1 March 2011

Bookmark : Hyper-V Dynamic Memory

Dynamic Memory is a new feature of Windows Server 2008 R2, as of Service Pack 1.

Ash has already had time to play with it and explains all in his post Enabling Hyper-V Dynamic Memory in Windows Server 2008 R2.

Remote Desktop : /admin and /console switch behaviour

Windows 2003
Using the /console connected you to 'session 0' i.e. the console session. If running Terminal Services you could have ended up with multiple sessions under the same username.
If using RDC client (Mstsc.exe) 6.1, /admin is used rather than /console

Windows 2008
Use the /admin switch only if you have Terminal Services installed to ensure you get the administration session.


Below, connecting to my windows 2003 backup machine using the /admin switch -



Support : Changes to Remote Administration in Windows 2008