T-SQL Row Count in a Table

In T-SQL usually we use the below query to get the total number of rows in a table

SELECT COUNT(*) FROM tblEmployeeMaster

There is another way to get the total number of rows in a table. But this is more efficient than the above one.

SELECT t.object_id ,t.Name,i.index_id,i.rows FROM sys.tables AS t INNER JOIN sys.partitions AS i
ON t.object_id = i.object_id WHERE i.index_id < 2  AND t.object_id=OBJECT_ID(‘tblEmployeeMaster’)

Of course, you can remove the condition “AND t.object_id=OBJECT_ID(‘tblEmployeeMaster’)” to view all the tables and their row count.

See the performance of the both queries using the Execution Plan

Execution Plan - Row Count

Execution Plan - Row Count

From the above execution plan you can see that Query 1 takes less execution cost than Query 2. So, Query 1 will give good performance than Query 2.

Freeze HTML table header

I am developing a reporting system using the classic ASP.  Most of the reports are displaying using HTML tables.  The table has 100 rows or 1000+ rows.  I had problem with the table header row.  If I place the table inside a <div> tag then header will also scroll hence while seeing the bottom rows users not able to find the columns.

So, to resolve the issue I did web search to find any tool available in the web to freeze the HTML table header. I got more results from the search.  But all the things are browser specific codes (like CSS and javascript)  and little difficult to implement. Hence I continued to search until get the right tool with all browser support and simpler to implement.
Finally I got a great tool to freeze the HTML header rows.

Visit the site Super Tables – HTML Tables with Fixed Headers to get the tool.

Its very simpler to integrate and supports for all major browsers.

This tool will helpful for large rows & column in the HTML tables.

Hope this will be useful to you :-)

Regular Expression and cheat sheet

A regular expression is a set of pattern matching rules encoded in a string according to certain syntax rules. Although the syntax is somewhat complex it is very powerful and allows much more useful pattern matching than say simple wild cards like ? and *.

Regular expressions are useful in the production of syntax highlighting systems, data validation, and many other tasks.

The below link explains the 8 regular expressions you should know for your projects. Here the expressions are explained by using the graphical pictures hence easily can understand.

http://net.tutsplus.com/tutorials/other/8-regular-expressions-you-should-know/

You can also get the Regular Expression Cheat Sheet for reference.

Post data to url using ASP Classic

We can post the data to a different URL using the MSXML2.ServerXMLHTTP object in classic ASP.

See the forum link ASP equivalent of Curl to get the code for this.

Add Application Extension in IIS 5.1

Its important to add the application extension for a custom Http Handler written in ASP.Net.

The below are the screenshots shows how to add the application extension in IIS 5.1, Windows XP.

Open the Internet Information Service(IIS), Right Click on Default WebSite and click Properties.

Default Website

Default Website

Add Application Extension

Add Application Extension

Add Application Extension

Add Application Extension

A forum discussion found on the web about adding Application Extension.

Convert negative value to Hex

Yesterday, my colleague came to me to ask a VB.Net code snippet for removing the front ‘F’s from a Hexadecimal number. I wondered and asked to him, why you want to remove the ‘F’s from the Hex. He explained that, ” I have a calculation which will return the resultant as negative value. If I convert the negative value into Hex and it will come like FFFF01395. But I want final result only 01395 “. After finished his explanation, I asked to him, if your final value may be F0D6 then what you will do. And I just told to him that removing ‘F’s is not the correct solution for your tasks.

So, we just googled like “negative int to hex” and got a forum link which where discussed about it. I wondered by seeing the solution. The below is the example they provided.

Scenario

Just take the Windows calculator and type -620 and convert it into Hex. The result is FFFFFFFFFFFFFD94. Then again without any changes just click Dec. The result must be -620. But the result is 18446744073709550996. Wow!!

Solution

= -620 + (2 ^ 16)                           [ 16 bit ]

= -620 + 65536

= 64916 (Base 10)

= FD94 (Hex Value)

So FD94 is the right answer.

I got new experience from him.

Creating demo version of ASP.Net Application

I found a great article about to create the demo version of ASP.Net Application. This is very useful to the ASP.Net application project developers.

Follow

Get every new post delivered to your Inbox.