Showing posts from 2009

SQL Server @@ROWCOUNT returns 1 if Min Max used in query


I came across this crazy issue today. You expect @@Rowcount to return number of rows returned by query right. But in my case it was returning 1 for 0 rows returned.
Here is an example.

FROM yourtable WHERE 1 = 2


But if you have MIN function being used, the result will be different

declare @company_id int

SELECT @company_id = min(company_id)
FROM yourtable WHERE 1 = 2


Apparently, since NULL was the result set, @@rowcount was giving 1 as the count.

I hope this helps someone.

SQL Server Insert Into Identity Column

We all know that if you have an identity column and if you try to insert a value in the identity column, you will get an error. Here is how you can avoid the error

First thing to do here is to set Identity to ON on the tblname you want to insert row in.


INSERT tblname (ID,colname) VALUES(5,'ajas')


Do not forget to set IDENTITY_INSERT to off once you are done with inserting the record because you dont want it to be off if you have an application where developers will be working on it.

Hope this Helps.

RDP End a Disconnected session

We all have had issues where in a RDP disconnected session wont allow other users to login until the administrator manually kills that disconnected session. Well, I just found out that there is a setting in Windows Server 2003 which would allow to automatically kill a RDP Disconnected session.

Go to Start - Administrative Tools - Terminal Services Configuration.

In Terminal Services Configuration, select Connections - RDP-Tcp. Right click RDP-Tcp and select properties. Go to sessions tab and select override user settings which is disabled by default. Here is a snapshot of the setting.

Many thanks to Cameron Childress for this post titled
How to Automatically Log Off Disconnected Remote Desktop / Terminal Services Sessions

This article is also good.

Lets Fifa - Fifa 10 Demo Trailer

Its that time of the year again. Yes, Fifa 10 demo is available for download.

Here are some videos of previews. Enjoy!!!

Awesome trailer


SQL Server Hidden Gems Perhaps

If you ever wanted to get name of all the databases on your server, you can use this query

In SQL Server 2000, select name from master..sysdatabases

In SQL Server 2005, select name from sys.databases


ColdFusion CFID CFTOKEN Get lastvisit timecreated from CGLOBAL

I had a recent need to get information of CFID & CFTOKEN to see how many records we have in our datasource for CDATA, CGLOBAL and also from which date i.e. Last Min date to Last Max date the CGLOBAL table has values for. So I wrote this short query and then finally i cast the column as datetime so we can sort by date otherwise the sort will occur by string.

select cast( substring(data, charindex('ts',data) + 4 , 19) as datetime) as 'lastvisit' ,
cast( substring(data, charindex('ts',data,charindex('ts',data)+4 ) + 4 , 19) as datetime) as 'timecreated', lvisit from cglobal

where charindex('ts',data) gets the first occurrence and len('2009-08-18 22:36:55') gives you an idea of how many characters you need to extract and turns out its 19 characters.

Link to how ColdFusion Purges Client Variables

Hope this helps someone.

ColdFusion Optimization Performance tuning

SQL Server Hidden Gem - How to get next value of Identity for a column in a table


This is very nice tip if you ever wanted to find the next value of identity column without doing an insert, I repeat without doing an Insert.

Lets say you have a table named company. Then you would use this command

SELECT IDENT_CURRENT('company') + IDENT_INCR('company')

where IDENT_CURRENT gives the current or last identity value used by that table and IDENT_INCR gives the increment you/anyone had set during creation of table. It could 1, 2 etc depending on your logic.

The other way of finding next value of identity is after an insert statement by using SCOPE_IDENTITY(). You would add 1 or 2 and so on depending on the autoincrement setting you used during the table creation.

Hope this helps.

Spread The MAX Widget Around, Win Cool Prizes


Unable to RDP. Enable Disable Microsoft Terminal Services Client Control mstscax.dll

So today i.e. Aug 17 2009 I was not able to remote desktop to my work computer from home. I am on WinXP Pro SP 2 with Internet Explorer 7 and I was able to remote desktop earlier without any issues.

Today, I was getting the popup message saying you need to install active x control. See below

I knew this had to do with Microsoft Terminal Services Client Control mstscax.dll and you need to enable it for RDP to work. For some reason, Internet Explorer 7, in its manage or enable disable add on feature wont show the Microsoft Terminal Services Client Control mstscax.dll. Here is a way to make it available so you can enable it.

1. When you get the pop up to install active X control as pop up , you get 2 options, Run and Dont run (install or dont install basically). I selected Dont Install. I will tell you later why I picked dont install, so hang on to that thought ;-).

2. Once I selected dont install, I got an small alert box or message info in yellow box from Internet explorer saying click…

Dalcha v/s Hawks. Aug 1 2009. Final.

After 3 weeks of thrilling and exciting games, it's the Hawks who won the CPL trophy. Like any other league game, this match was no different and the Hawks had to work hard to win the finals as the Dalcha's pushed them to the limit. We witnessed Ujwal's semi final performance which was unbelievable and in the finals, it was his counterpart Sagar, who performed brilliantly, to lead the Hawks to a famous victory.

The Hawks started with Sashi and Bhavin. Binnoy opened the bowling and gave only 5 runs of the first over. Sashi got out going for a big shot and Vinay joined Bhavin at the crease. Bhavin hit a six and four of consecutive balls and Hawks were looking good again with 16 for 1 after 2 overs. Vinay who played brilliantly in the semi final, couldnt get it going as He was not given any room by some fiery bowling from Binnoy. Kareem bowled well in the next over and got another wicket, this time of Vinay who made 5. Ujwal brought himself into the attack and got the prize wi…

Birthday Cake using Coldfusion & SQL Server

So, I made this cake for one of my colleagues at work, M.J. , and I was thinking what to write on the cake.

After a while, I got this idea of why not write something which she does, i.e. write queries every now and then.

So, I wrote a CFQuery tag for her on the birthday cake.

ColdFusion is the way to go, pretty much, in normal life too. ;-)

Blazers v/s Hawks. Aug 1 2009. Semi Final 2.

Who is the man, you ask and I say, Bhavin. Fantastic, Amazing, and Brilliant, at his best; He has performed in every game and He didnt dissapoint his team in the Semi Final against Blazers. He stood tall again and his innings along with Vinays power hitting, made the difference to the game. Before I go into the match details, one more thing, I would like to add. For some reason, I forgot to give credit to star batsman Vinay, for his beautiful innings on the opening day when He scored 30 plus. When I wrote Preview for Semi Final 2, I wrote about him as one of the danger batsman to watch out for and also updated the bulletin page for that game.

The Blazers won the toss and elected to field first, which I guess most captains did in CPL and won 90% of the games. So nothing wrong with that. Sashi and Bhavin opened the innings and Ravi Bachala bowled the first over. He gave only 8 runs and it was a decent start. The Hawks started carefully and by end of 4, they were 36 for 1, with Sashi gone…

Veterans v/s Dalcha. Aug 1 2009. Semi Final 1.

The word Ujwal means bright or you can say shining. Indeed, true to its meaning, Captain Ujwal shined when his team needed the most. He remained calm and cool and bowled probably the best over of the tournament, when it looked like they were going home early from the party.

Radha won the toss and elected to field first which was no surprise as the field was wet and conditions suited the team batting second. Ashish opened the batting with Harsha. Ashish started the proceedings with a big six over squre leg region in the very first over as 9 runs came of it. Good start right. Radha gave debutant Ramesh, who was a last minute addition, the 2nd over. What does Amchi Mumbai boy Ashish do? Well, He saw the first ball and defended it. Next ball, He whacked it way over long on for a big six. But next ball He tried again but this time it took an edge and He was caught behind by Keeper Rajesh. Another wicket fell in same fashion in the same over. End of over 2, Dalcha were 17 for 2, out of which…

DareDevils v/s Blazers. July 27 2009. Match 18.

Ravi Bachala's timely 31 enabled the Blazers to another victory. He put up a show of classy batting today for the Blazers. DareDevils fought back well but could not come up with a win. What this means is that DareDevils are out of semi final race. They play Cheetahs next in the last round robin game of the tournament.

The Blazers won the toss and elected to bat first. Ravi Bachala started the innings with Ravi K. By the time, the first wicket fell, Blazers had scored 19 of 2 overs. Ravi Bachala was timing the ball well and hit 2 sixes and 2 fours on his way to an impressive 31 runs. When He got out, the score was 59 in 5 overs. This was the break through, the DareDevils needed, as they tightened the screws on the Blazers. Sunil played his part and scored 10. Ramesh batted sensibily along with debutant Makam Ravi, to take the Blazers to a total of 84. For DareDevils, Suman took 3 wickets with his accurate bowling.

The DareDevils lost a wicket in the first over. Vinod joined Suman and…

Blazers v/s Veterans. July 25 2009. Match 17.

A power packed innings from Manohar resulted in a win for the Blazers in a tight last over finish. The Veterans and Blazers gave an impressive performance but Manohar's innings made the difference.

The Veterans were put in to bat by the Blazers. Shiva looks to be like Sehwag for the Veterans as He hit 2 big sixes again, one in the very first over. He made a quick fire 17. Rajesh and Radha formed a good partnership and both top scored for the Veterans with 26 runs. Both hit some amazing shots over square leg and mid wicket. Rajesh hit 3 fours and a six, Radha hit 2 sixes with one four. The Veterans scored a challenging total of 90 runs in their 10 overs.

The Blazers started with Dennis and Ramesh. Ramesh, minus his usual business formal dressing this time, started with a bang as He hit a big six over square leg. He followed that with another six and Blazers were right on track. Dennis played his part and hit a huge six over mid wicket region and the game was going away from the Veter…

DareDevils v/s Power Builders. July 25 2009. Match 16.

The DareDevils registered their first victory of the tournament eventually knocking out Power Builders from the semi final race. Some decent batting from DareDevils made sure they got a much deserved victory in only 8 overs.

DareDevils won the toss and asked Power Builder's to bat. The Power Builders started well with Satish and Harsha. Harsha scored 20 and Satish top scored for the Power Builders with 31. The Power Builders were 37 for 1 after 4 overs and finished with only 73 in 10 overs as no other batsmen performed. Mohan picked up 3 wickets for the DareDevils followed by Senthi and Selva with 2 each.

The DareDevils started with Abhishek and Suman. Abhishek took the game away from Power Builders as He hit 2 big sixes. This is just what DareDevils needed after their tough loss a day before against the Veterans. After 2 overs, they were 22, way ahead of the required run rate. Karim bowled his heart out and gave away only 2 runs, with 1 wicket, in the 3rd over to bring back the Pow…

Cheetahs v/s DalCha. July 25 2009. Match 15.

The Cheetahs found themselves unlucky again as the match ended up in a very close finish. The Dalcha's would be very happy to get their 3rd win when it looked like they are about to throw the game away.

Cheetahs won the toss and asked Dalcha's to bat. The Dalchas started badly and were 3 down for 25 at the end of 5 overs. In came captain Ujwal and Arif to the crease. They started rotating strike well and got 25 runs in next 2 overs. They were 49 for 3 after 7 now and were heading towards a decent total. But Ujwal and Arif thew caution to the wind and started going after the bowlers. The last 3 overs resulted in 40 runs and Dalcha were sitting pretty with a total of 89 in 10 overs. Ujwal played a captains knock and top scored with 44 not out, with 4 fours and a six. He was very well supported by his partner Abdul Razzaq a.k.a Arif, who scored 32 not out with 3 sixes.

The Cheetahs started with Anand and Ganesh. Ganesh was first to go, bowled by Karim. Anand played good and hit a s…

Veterans v/s DareDevils. July 24 2009. Match 14

Winning is a habit they say and Veterans are the only team so far with this habit. They got their 4 straight win today with another team performance. The DareDevils were in the game but could not finish the game on a winning note.

DareDevils won the toss and put the Veterans to bat. Shiva opened the batting for Veterans and started with his usual style as He hit a six. He got out trying to go for a second run and was well short of the creaase. The other batsmen struggled to get going and suddenly the Veterans found themselves in a big hole with 7 down for only 34 runs in 6 overs. The last pair of Nilanjan and Uma started getting runs and it was looking like the Veterans would not finish their full 10 overs. But credit to Nilanjan and Uma who made sure there were no more damages and they continued taking ones and twos, followed by odd boundary. Nilanjan top scored for Veterans with 16 and Uma scored 12. Together, they put a 31 runs partnership for the last wicket. The Veterans made 65 a…

Hawks v/s PowerBuilders. July 23 2009. Match 13.

Just last night, I finished writing about Kareem from Dalcha. Today it was another Karim from Power Builders, who hit some crazy Afridi style sixes to guide Power Builders to a victory. The game was full of excitement and pressure. The Power Builders gave a complete team performance, much like their opponents, Hawks.

Sagar won the toss and elected to bat first. The opening duo, Sashi and Bhavin started well. They put on 18 runs of the first 2 overs. Bhavin scored 16 and Sashi made 8. The Hawks went for their shots and were caught on the boundary. Satish of Power Builders was very impressive as He caught 3 catches in the deep. Vinay was playing well and was making the life difficult for fielders, especially at long on as the ball would turn twice or thrice before reaching the fielder. You all know who was standing there. :-). Vinay was caught on the boundary by an absolutely brilliant one handed catch by Harsha. Vinay top scored for Hawks with 22 runs and in the process, hit some beauti…

SQL Server Deadlocks. Applies to 2000 and latest, 2005 2008 versions

Found a very good article about SQL Server 2000 Deadlock problem.

Here is the link SQL Server A Deadlock Occurrence and Resolution

Replace, Substring, CharIndex magic / usage in SQL Server 2000


This post covers 3 amazing functions in SQL Server 2000 ( I am sure you can use them in SQL 2005 or 2008 for that matter). They are Replace, Substring and CharIndex.

So my challenge was to replace ssn in a text and return the full text with only SSN part formatted as SSN : xxx-xx-1234 format. So I combined these functions this way.

1. first find the place/locations where the text SSN appears in the column using

2. then use Substring to use the number returned from step 1 and give the lenght of characters to be returned
substring(status,charindex('ssn',status), 11)

3. Finally use replace function, to use step 2 and step 1 i.e. replace the characters returned by both steps with your text i.e.

select replace(status, substring(status,charindex('ssn',status), 11), 'SSN : xxx-xx-') from sometable where condition = condition.

Hope this helps.

ColdFusion All Scopes Local Variables using Java getPageContext() Method


You might have heard about CF's undocumented features. One of them came in really handy for me. Its the getPageContext() Method. Using this method, we can list all variable scopes. You could do something like this

<cfdump var="#getPageContext().getVariableScope()#"> or
<cfdump var="#getPageContext().getBuiltInScopes().Variables#">

to get local variables scope and similarly for other variable scope. I read about this method at 2 great blogs, one by Ben Nadel and other by Mark Kruger.

Hope this helps.

Internet Explorer Terminal Services TS Remote Desktop Add On Prompted to enable but not in the list issue Windows XP SP3


One of our colleague got a new Dell Latitude laptop and when he was trying to remote desktop i.e. remotely login to his work pc, he was getting a message in Internet Explorer saying You need to enable the add-on or Active X control needs to be installed.

Step 1. If the Active X control is not installed, please go ahead and install it.

Step 2. If you are still not able to access remote desktop and get message saying enable the add-on, you would have to download XP SP3, extract the files and run the following 2 files

Tscdsbl.bat Tscuinst.vbs

That fixed the problem for me.

Hope this helps.

How to write CFID and CFTOKEN as per-session cookies

Nice Article from Adobe highlighting CFID & CFTOKEN, and How to write CFID and CFTOKEN as per-session cookies. Worth Reading.


Dreamweaver CS4 - Cool Stuff - Share My Screen - Code Split - View Related files


I just ended up installing DW CS4 and I noticed some cool features.

1. Go to File Menu, and select Share My Screen.
Within minutes after you install Adobe Connect Plug In and the user you invite installs the plug in as well, you will be able to share screens.

It just took me and my co-worker(thanks MJ), 2 minutes to test this feature.

2. Another feature. Code Split. You can split the code into 2 parts, so you could be scrolling the code in top section and view the top part or any part at the bottom view. To do this, in your DW, on the very top next to where Menu ends, there is a layout button. If you click on that, you will see different options and one of them is split code.

3. The one I really like the most is the *View Related Files*. We have several includes in our coldfusion code and this features lets me see all the files that are related to this cfm template.

I will update this post later.

Till then,


Great Sitepoint Books, Now on Sale. PDF Format. The SitePoint 5-for-1 Sale (3 days only!)

Hello there,

If you ever wanted to learn any technology or anything related to IT, please check out the books from Sitepoint. They are very thorough and have in depth explanation of topics with very good examples.

To sweeten the deal, sitepoint is having a good sale going on now for there books in pdf format. Its called The SitePoint 5-for-1 Sale (3 days only!).

Go here or The SitePoint 5-for-1 Sale (3 days only!)

If nothing works, just paste this url in your browser.

I can guarantee that this would be the best purchase you would have done for yourself.


Fifa 09 PS3 Watch Rooney and Higuain play against each other.

I saw this video and it was amazing feeling. No wonder, soccer is the beautiful game we know.

Watch this.

I got this link from this site