Feeds:
Posts
Comments

Mobile Phone Tragedy

This is one of my not-so-technical blog entries… but keep on reading because you never know it might hit you one day

To cut the story short, I was visiting a friend the other day and my mobile phone fell into the toilet. I’m being nice as to spare you the details, but yeah I washed my phone with clean water and dried it immediately with tissues. I was rather impatient so I used my friend’s hair dryer (I needed the phone to call home!) and violently shook the phone to get the water out. I reinserted my SIM card and the battery (bad move?) and turned on my mobile. It’s turned on but it can’t recognize my SIM.

Fast forward to today, I’ve cleaned up my mobile thoroughly with methylated spirits. Checked the SIM card, it works on the other mobile but my poor mobile still doesn’t like it. Checked with another SIM card, same case.

I reformatted the phone by restoring everything to factory default setting ( after saving whatever I can from the phone – photos, files etc). Reformatting went fine, however it didn’t help. It is still rejecting my SIM card.

Losing patience, I bid a phone off eBay and boxed my unfortunate mobile phone. Maybe one day I’ll get it fixed, preferably when I am away on my Asian trip, heard they fix it cheap there… :)

Lesson to be learned:
When your mobile phone is wet, take apart everything you can and let it dry for at least 2 days. Do NOT try to insert the battery at all times!

I know this is kinda outdated, but it’s still good to know…

I admit ASP/HTML programming is not really my strong suit and my knowledge is least to say about 5 years old, which also says I don’t remember much… Anyway, I compiled these tips some time last year and thought it would be good to share with people, just in case you have to deal with ancient products one day.

To call an ASP file

You will need to have IIS set up on your local machine (if you’re running it from your own computer). Just install it by going to your Add/Remove Programs in Control Panel. Choose Add/Remove Windows Components and make sure that Internet Information Services (IIS) is ticked. Once installed, go to your local harddrive, click the Inetpub folder and copy your asp file in the wwwroot folder. You may also create a new folder (eg for testing purposes or whatever) in that wwwroot folder.

Open your browser. Type in http://localhost/[folder]/[filename].asp and enter.

To include a script in an asp file

< SCRIPT LANGUAGE=”VBScript” EVENT= “onsubmit” FOR=”btnsubmit >
<% script here
% >
</SCRIPT >

To include a script in a html file

< SCRIPT LANGUAGE=”VBScript” EVENT=”OnClick” FOR=”btnSubmit”>
< !– script here
–>
< /SCRIPT>

If you need to include html tags in your blog

When I wrote my examples above, the HTML tags are automatically converted. To ignore HTML tags, I use &lt; and &gt;. This will display the HTML code with its tags (Don’t forget the semicolon!)

In my course of work, I monitor several replications regularly. When everything goes well, it just takes literally a couple of minutes. But when a problem strikes, it may eat up half my day.

Just this morning, when I thought everything was looking dandy, there was one replication that has its status turned to ‘Performance Critical’. That’s a step below ‘Error’ but over ‘Running’ on the severity error ladder. What does it mean? And how did I solve it?

It all began with me troubleshooting a ‘transaction log is full’ error. Our company policy states that no database in UAT and DEV should have a FULL recovery. This precaution is meant to save some spaces that normally would be used by the transaction logs. Somehow this particular database is in full recovery and had been actively logging until it ran out a space. So I set the recovery to SIMPLE and shrank the log file.

And it appeared. Although shrinking the log files should remove the problem as it removed the multiple virtual log files, the latency increased. My solution to this is to reinitialize the subscription and that works well. Or to the extreme, recreating the publication (remember that I do this thing in UAT!). You may also adjust the threshold setting, however I am not awfully keen as it means to reset the performance standard.

Reference: SQL Server 2005 BOL “Monitoring Performance with Replication Monitor”

SCOM: Riding Overrides

Question: How do you disable a rule in a sealed MP and show that rule is disabled?

This is another question that I encountered with OpsMgr aka SCOM 07 (I am counting…!).

Facts:
1. All the rules have default Yes/No in the Enabled column.
2. You wouldn’t be able to disable/enable a rule if the Management Pack is sealed.

The preferred way to enable/disable a rule of a sealed MP is via an override, which means changing the Enabled value to True/False. It is a pain in itself because:
1. God knows how many rules that you have to disable/enable, not to mention changing other parameters, but that’s a problem for another day.
2. When you create an override, there’s no easy way to see if the override has been applied because (a) it is still greyed out or not greyed out in the console and (b) the Enabled by default value has not changed. I know, I know… you may say it’s cosmetic, but wouldn’t you like to be able to point out straight away if a rule is enabled/disabled – without too much efforts, that is.

OK, let’s solve one thing at a time.

You CAN actually enable/disable multiple rules. Boris Yanushpolsky has created this awesome tool called Override Creator which allows you to enable and disable multiple rules at once. That’s about it. I reckon it saves you half the work, at least. The other half? No such luck, my friend, you gotta do it manually :)

To view all the overrides, use Override Explorer. This simple tool lists all the overrides applied in a Management Pack or in a server. There is no so-called a user manual, but the application is quite intuitive and after clicking around several times, I found my way.

Another tool that I found useful is the MP Viewer. The tool will give you an overview of a Management Pack: overrides, dependencies, views, etc. Works on both sealed and not sealed MPs.

Before I reveal the solution for No2, let me say this: this is experimental only and it is not in production. I have not yet investigated the full impact of what I did and I am not sure what sort of implication it may bring. I just want to show you what’s possible. It would be great if someone from the System Centre Community (http://systemcentercommunity.com/) can blog about this and gives a full-on explanation, but at the time of writing, no such thing.

All right, having said that, let’s dig.

When you go to the Authoring mode and check out the Rules under Management Pack Objects, you would see something like this:

OR1

Collect Transaction Log Free Space (MB) rule in SQL Server 2005 (Monitoring) pack is disabled by default. You wouldn’t know that this rule has actually been enabled via an override.

OR2

So I went to the OperationsManager database and run the below query:

SELECT RuleName, RuleCategory, RuleEnabled
FROM Rules
WHERE RuleEnabled =0
AND RuleCategory =’performancecollection’
AND RuleName like ‘%transactionlog%’

Here’s the result:
OR3

So we want to enable the Microsoft.SQLServer.2005.Database.TransactionLogSpaceFree.Collection rule.

UPDATE Rules
SET RuleEnabled = 4
WHERE RuleName =’Microsoft.SQLServer.2005.Database.TransactionLogSpaceFree.Collection’

Why 4? Any value above zero in reality will enable the rule (1-4). There’s no formal explanation of these numbers (URL? White paper? Books? Blogs? C’mon, someone must have known something!), but my observation concludes the following:

    0 – rule is disabled
    1 – not used for anything
    2 & 3 – for Windows Server MPs
    4 – for others (System Center MPs, SQL Server MPs)

So number 4 it is!

Here’s what it looks like after. See my point about visibility? Now you can tell straight away if the rule is enabled.

OR4

Other Reference:
Jakub Olesky – Overrides

Kill Multiple SPIDs

Quite a handy script if you want to clear out ALL spids connected to a database.

USE master
go

DECLARE @dbname sysname

SET @dbname = ‘yourdbname’

DECLARE @spid int

SELECT @spid = min(spid)
FROM master.dbo.sysprocesses
WHERE dbid = db_id(@dbname)

WHILE @spid IS NOT NULL
BEGIN
EXECUTE (‘KILL ‘ + @spid)
SELECT @spid = min(spid)
FROM master.dbo.sysprocesses
WHERE dbid = db_id(@dbname) AND spid > @spid
END

If you have an access to your desktop via a VPN, you’d realise that you won’t be able to lock your desktop remotely using Ctrl + Alt +Del or Windows + L .

To work around this issue, the easiest way is to create a shortcut on the remote desktop to lock the work station.

1. Right click to the empty space on your remote desktop, point to New and click Shortcut.
Pic1

2. A Create Shortcut box will pop up. Type into the Type the location of the item field : c:\Windows\System32\rundll32.exe user32.dll,LockWorkStation

Pic2
Click Next

3. Type a name for the shortcut (anything you fancy!). Click Finish
Pic3

4. Now we have the shortcut on the desktop. Doesn’t look too good eh?

Pic4

You can get a free icon from iconspedia.com or others if you’d like to change the icon image. Here’s what mine looks like after adding the icon.
Pic5

Too easy! All you have to do is double click on the icon and your PC is locked.

Hi there, thanks for reading my blog! Hope you find the content useful for your day-to-day work. As you know, I am at the early stage of my DBA life and thinking it will be interesting to blog what I learnt over time.

Time to get a bit serious, I said and I am taking it one step ahead at a time. I recently registered for a domain name to use with wordpress. Why? Because it’s easier for people to remember my blog’s name than my name! :)

Here it is: http:\\techscribbles.com

You still can access my blog through the wordpress address. From my understanding, you will be automatically redirected to the new domain account so please refresh and update your bookmark.

Got questions? Drop me a line!

Here’s my list:

1. By GUI On Object Explorer in SSMS, right click the server then click Restart.

2. By Cluster Administrator Go to Administrative Tools>Cluster Administrator. Click Open. Select Action: Open connection to cluster and type or select the cluter/server name. Click OK. Expand Groups. Select the instance that you want to restart. Right click and select Take Offline. Right click again and select Bring Online.

3. By SQL Server Configuration Manager
Log into the server via Remote Desktop Connection. Open the SQL Server Configuration Manager (Programs>Microsoft SQL Server 2005>Configuration Tools). Select SQL Server 2005 Services. On the right hand panel, right click SQL Server (MSSQLSERVER) and select Restart.

4. By Services
Log into the server via Remote Desktop. Open Services in the Administrative Tools. Scroll down and find SQL Server (MSSQLServer). Right click and select Restart.

If you know another way than those listed, please write a comment, so I can update the post. Thanks!

Some time last year, I had a brief encounter with SCOM. I was happily playing around with it, reading SCOM materials and blogs (Jakub Olesky’s , Kevin Holman’s, etc) and trying on some hands-on materials, such as writing a script with MOMAPI.

One day, I was inundated by hundreds of thousands of SCOM alerts. Needless to say, this incident brought the server to a grinding halt. The culprit? An unclosed loop spitting alerts every minute.

Feeling rather depressed, I took this to my manager’s notice. After checking the situation, he declared nothing major had happened and I would need to delete the alerts so everything would be (or should be) back to normal. I Googled for a solution and found that someone got it bad too… I suddenly felt not so depressed anymore.

OK, basically what you have to do is to update the open alerts in the database to ResolutionState = 255 (Closed), like this:

UPDATE dbo.Alert
SET ResolutionState = 255, TimeResolved = GetDate()
WHERE ResolutionState = 0
AND TimeResolved IS NULL

Then clear the console cache from command prompt:

cmd> “C:\Program Files\System Center Operations Manager 2007\Microsoft.MOM.UI.Console.exe” /clearcache

All active alerts will be down to 0.

Make sure that you don’t set your database growth to automatic. There’s a possibility that the queue hasn’t finished popping the alerts and you may see alerts flowing back again.

This battle fortunately had a happy ending (after couple of weeks!). My aftermath cleaning up tasks include:

1. Making sure that the database is not growing out of proportion. Untamed growth will cause the system to go slow, your machine will break down and you will find yourself rebooting every 2 hours or so.

To trim the database:
DELETE FROM Alerts WHERE ResolutionState = 255

You may set the rowcount, say, to 5000 and run it 1000 times!

2. Consider to reinstall the SCOM console. Some files may have been corrupted and can disrupt your future work if you don’t fix it.

All been said and done, the monster has been laid to rest… for now.

Do you see something like this in your database?

    DOMAIN\login.myTable
    Username.myView
    Username.someStoredProc

Sometimes these objects are created ”accidently” under user’s schema. So how do we change it back to dbo or to other schema?

ALTER SCHEMA dbo TRANSFER DOMAIN\login.myTable

This will alter the schema of myTable to dbo.

Want to dig more information for schemas in the database?

USE database_name
GO

SELECT * FROM INFORMATION_SCHEMA.SCHEMATA

You will be able to view the

    CATALOG_NAME,
    SCHEMA_NAME,
    SCHEMA_OWNER,
    DEFAULT_CHARACTER_SET_CATALOG,
    DEFAULT_CHARACTER_SET_SCHEMA,
    DEFAULT_CHARACTER_SET_NAME

Use ALTER AUTHORIZATION if you need to change the schema owner.

For example: you want to change SampleSchema owner to MySchemaOwner

ALTER AUTHORIZATION ON SCHEMASampleSchema TO MySchemaOwner

ALTER AUTHORIZATION is generally used to change ownership of a securable, including object, database, role, schema, certificate etc.

BOL references:
http://msdn.microsoft.com/en-us/library/ms173423.aspx
http://msdn.microsoft.com/en-us/library/ms182642(SQL.90).aspx
http://msdn.microsoft.com/en-us/library/ms187359.aspx

« Newer Posts - Older Posts »