Read Consistency behavior in SQL Server 2000 and 2005 with isolation level

Hi

An interesting question came up, when I was discussing some point on database isolation level with my colleague. The point was that to get a read – consistent view to all the transactions in the database what isolation should be there.

The point got more interesting when we found that there is a difference in how this works in SQL Server 2000 and SQL Server 2005.

In SQL server 2000 we get the read consistent view to all transaction in the database only in the SERIALIZABLE isolation level. Any other isolation level we can perceive uncommitted dependency (also called dirty reads), non-repeatable reads or Phantom reads.

Continued...

Microsoft provided free SQL Server 2000 tools.

Hi

There are many things that we want to do in SQL server which do not ship with the product but are still freely available. There are many free tools available for SQL server that are less known to the developers because they do not ship with the product. But these tools can be more than handy for many situations. And very importantly these tools are freely available from Microsoft.

Here is a list of tools available from Microsoft freely for SQL server 2000. [Note: These list is not exclusive. There are more tools available from Microsoft. Please check Microsoft’s Site for the same.]

Read80Trace - It is a command line utility for processing trace files generated by SQL Server 2000.

Continued...

Process class and some small demo code

Hi

I just found some simple code that I have used in my previous application related to process in a windows application.

Many a time we want to run some external application from our windows application. To do that we need top start the process for that application. Lets say we want to start the WordPad application from our window application.

Process proc = new Process();

proc.StartInfo.FileName = @"Wordpad.exe";

proc.StartInfo.Arguments = "";

proc.Start();

This will start the word pad application in the system. If we give provide an web address as the file name then the default browser will open with the given URL.

Continued...

Blog, Ping and update status. How does it work?

Hi,

As we all know the world of the Blogs work on the ping services. Once we update our blog with new posts we need to update the other sources that our blog has been updated. We should ping to the sources whenever we create or update our post.

Pings can be done both manually and programmatically. Many site provide free ping services for with a ping interface like http://ping.in/, http://pingoat.com etc. You enter your URL and and the feed title and they will ping all the ping server listed.

We can also ping programmatically. Programmatic ping is done through XMP-RPC Procedure, through which we send xml over the http request. The XML contains information of your feed and the URL to which you send the request is called the endpoint

Here is an example that I found that uses the xmlRpc Library from the cook computing.

Continued...

Some small changes made to the site for your usability

Hi

Of late I have done small changes to the site. I found there are some things missing for the user, so tried to make some very small changes in the system. One of the important things that I was very eager to do was to allow user to attach to site with the help of RSS and Atom feed.

Continued...

Adding dates in SQL Server using the add operator

Hi

In SQL Server we can add day to date in two ways. We can use the DATEADD function to add date like

SELECT DATEADD(dd, 2, GETDATE())

This adds one day to the current date. We can also use the following query to get the current date and add a one-day to it. Both the queries will give same results.

SELECT GETDATE() + 2

If you are thinking that why does an + operator produces exactly same results? Read on.

As we know that the datetime data occupies 8 bytes (4 of them stores number of days after or before January 01 1900 and the other 4v store number of 3.33 ms clock tics since midnight. All the number are stored as integer data type.

Continued...

SQL Server 2005 Bitwise Exclusive OR Operator

Hi

In SQL server 2005 if we want to perform a bitwise exclusive or operation between two integers then we can use the ^(Shift + 6) character. The exact syntax would be like

Expression ^ Expression

For example 3 ^ 2

The statement would return true since one of the expression evaluates true. Note this only works with expression integer category data types, bit, binary and varbinary data types.

The operator performs logical or , taking each corresponding for both expressions. The bits in the result are set to 1 if only one bits in the input expressions have value one. If both bits are either 0 or 1 the bit in the result will be cleared to the value of 0.

In case the two expressions have different integer data types (smallint, tinyint or int), the smaller data type argument is converted to the larger data type

Thanks
Vikram


Difference between Convert.ToInt32 and Int.Parse method

Hi

Today one of my colleagues came up with an interesting question in the office. If we want to convert a string value (Lets say we have a string “23”) to integer we have 2 options. One is to use the Int.Parse method and other is to use the Convert.ToInt32.

The real query with every one was what is the difference between the two. The answer is null handling. The difference between the 2 is the manner in which null is handled. If you pass a null value to convert.ToInt32 method it will return back 0. But the same is not true with Int.Parse. If we pass null to Int.Parse method it will throw an ArgumentNullException exception.

Although Convert.ToInt32 method does not throw an exception but it can have a big drawbacks. If you use it on a query string value(where u are also expecting the value 0) then the Convert.ToInt32 might cause programmatic error.

Thanks
Vikram


Finding the names of tables with or without primary in the database

Hi

One major aspect of database design that has been debated a lot is having primary keys. Normally a primary key would be the entry point to the data to perform DML action. Not having primary keys are not just bad for design purpose, but that can also cause major problems in replication. The problem can be even severe when we are importing when we are trying to import data from other data source and there might be some duplicate data there.

But Lets say you have a database already designed and you feel there are some tables that do not have any primary key. You have over 200 tables in the database so to find out manually which table has primary key, which do not can be more than tedious. But there is an easy way out. You can query the system tables to find out these results. Below are two queries to provide the list of tables with and without primary key.

--Query to find all the tables with primary key

Continued...

New features of C Sharp 3.0 LINQ (Language Integrated Query)

Hi

LINQ (Language Integrated Query) is the composition of many standard query operators that allow us to work with data of any datasource in a very intuitive way. LINQ provide compile time checking of query and the ability to debug through query.

To show a very basic example of what can be done with the help of LINQ I am using and in memory generic list collection that queried by LINQ.

Continued...

Javascript function for formatting number

Hi

A few days back one of my friend ask me to write an interesting JavaScript function. He was doing a lot of calculation in the form with the help of JavaScript, to the give the web page a desktop like feeling. Now he wanted to display the values in certain format.

The format was predefined but was different for different users. The for mat also required the commas to come at different places for different users. Like for user the value would be 1,00,00,00,000 and other it will be 1,000,000,000. Here the commas separation comes after different places for different kind of format. (The other complication of the function was that a comma instead of dot would some time represent decimal separation. But that’s not part of this post.)

Continued...

TSQL safety in the production environments with some programmatic effort

Hi

Yesterday I came across a very common but interesting requirement from a friend. Actually the requirement is very common for developer dealing with the database. Many a times a we have some SQL, TSQL code which we use during development but that should not run on the server.

Normally developers have a process of checking from the process prospective so that the code does not go on the server. But mistakes are inevitable. So we should also have a solution for the same from programmatic aspect. This is very important because some code (Like delete, or update statement) can cause big problem in the live site if they run by mistake also.

We should have a process to stop such error, but we can also take small care in the code itself to prevent any major problem. Some of the way are discussed below.

Continued...

Design pattern – What can they mean?

Hi

A few days back when I wrote the blog on design pattern a small but interesting question came to my mind. How and why did the design pattern started. So I started hunting in the google for my curiosity and found some interesting stuff. So I thought I would share them with you.

A repeatable solution for commonly occurring problem in the software programming is called design pattern. Design patterns are not finished designs for the problems, but are template and description on how the solve the problem, which might occur in different situations.  Design patterns commonly show relations and interaction of different class or objects or types. They do not specify the final class or types that will be used, but give an abstract view of the solution.

Continued...

A word about the observer design pattern

Hi,

A few days back on of my senior talked about different pattern and how useful they can be in the process of development. We were talking about the observer pattern. So I thought I will write a bit about the observer design pattern.

Based on the principal of implicit invocation, Observer design pattern (also known as publish Subscribe) is used in programming to observer the state of and object in a program. In many programming language the issue of this pattern are handled in native event handling syntax.

Continued...

Checking the Delete statement logic and the number of records deleted by it

Hi,

A few days back a friend of mine asked me a simple but tricky question in SQL. The question was how would you check that the number of rows deleted through a delete query and the logic of the delete query is correct.

I know the first answer that comes to the mind the @@rowcount variable. But that variable is good enough for the row count only. How do you verify the login of the delete statement?

Continued...

Asp.Net futures May - A look at the future of Asp.Net

Hi

A few days ago Microsoft Released the Asp.Net Futures. This is a list of futures that might be delivered in the future. I have still looked at only one of the Category and the list already looks promising and exiting to me. The functionality in the Futures release includes early experimental versions of features currently being considered for future versions of ASP.NET and the .NET Framework.

Continued...

How to capture the image of the screen according to the resolution using Dot Net

Hi

Today I was playing around with some window form and came up with a simple and interesting requirement. I wanted to take a print screen of the monitor from inside the application. What I wanted to do was allow the user to save the screen as and when they wanted it from inside the application.

So first thing I had to do for this was to find out the resolution of the screen that the user was working with. Because the screenshot need to be save of the same size as the screen resolution. This can be done by using the System.Windows.Forms.SystemInformation class. This class provides a static method PrimaryMonitorSize which gives us the monitor size. This property is of type Size. So we have width and height of the screen using the following code.

int width, height;

width = System.Windows.Forms.SystemInformation.PrimaryMonitorSize.Width;

Continued...

Tons of stuff available for beta download - IIS 7, Dot Net framework 3.5, Orcas and Silverlight

Hi

It seems to be the season of the beta download and beta testing again. Dot net developers have got tons of things to play with. Four most important products in their different level of Beta. Wow! Here is the list and the links to download

First we have IIS 7 in Beta 3 for download. Yes it also support the go live license. This means that you can use it in the production environment also. And is its stable? Well Microsoft.com is already deployed on this.

Some of the new features of IIS 7 are

Continued...
 
Copyright © 2006 - 2008 Vikram Lakhotia