Stop the transaction log of a SQL Server from growing unexpectedly

5 12 2008

In SQL Server 2000 and in SQL Server 2005, each database contains at least one data file and one transaction log file. SQL Server stores the data physically in the data file. The transaction log file stores the details of all the modifications that you perform on your SQL Server database and the details of the transactions that performed each modification. Because the transactional integrity is considered a fundamental and intrinsic characteristic of SQL Server, logging the details of the transactions cannot be turned off in SQL Server.

The transaction log file is logically divided into smaller segments that are referred to as virtual log files. In SQL Server 2000, you can configure the transaction log file to expand as needed. The transaction log expansion can be governed by the user or can be configured to use all the available disk space. Any modifications that SQL Server makes to the size of the transaction log file, such as truncating the transaction log files or growing the transaction log files, are performed in units of virtual log files.

If the transaction log file that corresponds to a SQL Server database is filled and if you have set the option for the transaction log files to grow automatically, the transaction log file grows in units of virtual log files. Sometimes, the transaction log file may become very large and you may run out of disk space. When a transaction log file grows until the log file uses all the available disk space and cannot expand any more, you can no longer perform any data modification operations on your database. Additionally, SQL Server may mark your database as suspect because of the lack of space for the transaction log expansion.

Reduce the size of the transaction logs

To recover from a situation where the transaction logs grow to an unacceptable limit, you must reduce the size of the transaction logs. To do this, you must truncate the inactive transactions in your transaction log and shrink the transaction log file.

Note The transaction logs are very important to maintain the transactional integrity of the database. Therefore, you must not delete the transaction log files even after you make a backup of your database and the transaction logs.

Truncate the inactive transactions in your transaction log

When the transaction logs grow to an unacceptable limit, you must immediately back up your transaction log file. While the backup of your transaction log files is created, SQL Server automatically truncates the inactive part of the transaction log. The inactive part of the transaction log file contains the completed transactions, and therefore, the transaction log file is no longer used by SQL Server during the recovery process. SQL Server reuses this truncated, inactive space in the transaction log instead of permitting the transaction log to continue to grow and to use more space.

You can also delete the inactive transactions from a transaction log file by using the Truncate method.

Important After you manually truncate the transaction log files, you must create a full database backup before you create a transaction log backup.

Shrink the transaction log file

The backup operation or the Truncate method does not reduce the log file size. To reduce the size of the transaction log file, you must shrink the transaction log file. To shrink a transaction log file to the requested size and to remove the unused pages, you must use the DBCC SHRINKFILE operation. The DBCC SHRINKFILE Transact-SQL statement can only shrink the inactive part inside the log file.

Note The DBCC SHRINKFILE Transact-SQL statement cannot truncate the log and shrink the used space inside the log file on its own.

Prevent the transaction log files from growing unexpectedly

To prevent the transaction log files from growing unexpectedly, consider using one of the following methods:

  • Set the size of the transaction log files to a large value to avoid the automatic expansion of the transaction log files.
  • Configure the automatic expansion of transaction log files by using memory units instead of a percentage after you thoroughly evaluate the optimum memory size.
  • Change the recovery model. If a disaster or data corruption occurs, you must recover your database so that the data consistency and the transactional integrity of the database are maintained. Based on how critical the data in your database is, you can use one of the following recovery models to determine how your data is backed up and what your exposure to the data loss is:
    • Simple recovery model
    • Full recovery model
    • Bulk-logged recovery model

    By using the simple recovery model, you can recover your database to the most recent backup of your database. By using the full recovery model or the bulk-logged recovery model, you can recover your database to the point when the failure occurred by restoring your database with the transaction log file backups.

    By default, in SQL Server 2000 and in SQL Server 2005, the recovery model for a SQL Server database is set to the Full recovery model. With the full recovery model, regular backups of the transaction log are used to prevent the transaction log file size from growing out of proportion to the database size. However, if the regular backups of the transaction log are not performed, the transaction log file grows to fill the disk, and you may not be able to perform any data modification operations on the SQL Server database.

    You can change the recovery model from full to simple if you do not want to use the transaction log files during a disaster recovery operation.

  • Back up the transaction log files regularly to delete the inactive transactions in your transaction log.
  • Design the transactions to be small.
  • Make sure that no uncommitted transactions continue to run for an indefinite time.
  • Schedule the Update Statistics option to occur daily.
  • To defragment the indexes to benefit the workload performance in your production environment, use the DBCC INDEXDEFRAG Transact-SQL statement instead of the DBCC DBREINDEX Transact-SQL statement. If you run the DBCC DBREINDEX statement, the transaction log may expand significantly when your SQL Server database is in Full recovery mode. Additionally, the DBCC INDEXDEGRAG statement does not hold the locks for a long time, unlike the DBCC DBREINDEX statement.

-Microsoft Support

The end of an era – Windows 3.x

5 11 2008

An application has expectedly quit.

Windows 3.x established the look of the operating system.

Windows 3.x established the look of the operating system.

Windows 3.x has come to the closing moments of its long life.

On 1 November Microsoft stopped issuing licences for the software that made its debut in May 1990 in the US.

The various versions of Windows 3.x (including 3.11) released in the early 1990s, were the first of Microsoft’s graphical user interfaces to win huge worldwide success.

They helped Microsoft establish itself and set the trend for how it makes its revenues, and what drives the company until the present day.

High flyer

For many computer users 3.x was the first Windows-based operating system they used, and the software established the iconography of Microsoft’s flagship product.
As it was updated the software started to make PCs a serious rival to Apple machines, as it could take advantage of much improved graphics, had a broader colour palette, and could use multimedia extras such as sound cards and CD Rom drives.
Microsoft maintained support for Windows 3.x until the end of 2001, and it has lived on as an embedded operating system until 1 November 2008.

As an embedded system, it was used to power such things as cash tills in large stores and ticketing systems.
One of its more glamorous uses as an embedded operating system is to power the in-flight entertainment systems on some Virgin and Qantas long-haul jets.

Tech specs

Stefan Berka, who runs the GUI Documentation Project, said the important technical innovations in the software were its extended memory that could address more than 640KB and the improvements to hardware support.
The fact that it was 100% compatible with older MSDOS applications helped too.
Windows 3.x required an 8086/8088 processor or better that had a clock speed of up to 10MHz. It needed at least 640KB of RAM, seven megabytes of hard drive space, and a graphics card that supported CGA, EGA and VGA graphics.
By comparison, the Home Basic version of Windows Vista requires a 32-bit 1GHz processor, 512MB of RAM, 20GB of hard drive space, and a graphics card with at least 32MB of memory.

“I haven’t received an e-mail about Windows 3.11 for a long time,” said Andy Rathbone, author of a Dummies guide to the software. “But I wouldn’t be surprised if some people still use it.”
Sales of the software still pop up on eBay, he said, but not at a price that would tempt him to part with his unopened copy of Windows 3.1.
Agent Quang from home IT support firm The Geek Squad, said he regularly encountered venerable operating systems in customer’s homes but it had been a long time since he saw Windows 3.x.
“The majority of machines we run see are running XP,” he said, “Vista is still a bit flaky here and there and people are not comfortable with it.”
But, he said, Windows 95 and 98 were still popular with some customers.
“We see them on laptops and people are unwilling to let them go,” he said. “It’s perhaps because in the early days laptops cost a lot more money they do now, and there’s much more perceived value there.”
Agent Quang’s personal favourite operating system was Windows 98 because, by the end of its life, the software was so solid.

Old Iron

He said anyone running an ageing operating system might face problems as they try to find a web browser that could run on it and display the latest online innovations.

“We had a case a while ago a customer with a Windows 98 machine trying to view her website and the pictures were just not coming up,” he said. “Eventually we had to install Netscape Navigator to get it working.”

Stefan Berka said he had recently re-installed Windows 3.11 on a computer and was surprised at the results.

“Personally, I had fun at my last Windows 3.11 test installation to make it a useful desktop operating system again,” he said.

“With patched SVGA driver for 1024×768 resolution, Internet Explorer 5, WinZIP, VfW and Video Player, it was still useful,” he said. “The desktop was ready after a few seconds loading time.”

Said Mr Rathbone: “Windows 3.11 would still work reasonably well today, provided it only ran software released around the same time.”

He cautioned against anyone considering returning to the olden days and using it as their mainstay operating system.

He said: “I wouldn’t connect it to the internet, though, as it’s not sophisticated enough to ward off attackers.”

BBC News

Authentication in ASP.NET

16 06 2008

Security is a major concern for both application architects and developers. Applications that store sensitive information need to be protected from malicious attacks and from competitors attempting to steal information or intellectual property. When designing a security model for your application, you need to be aware of security requirements from a business perspective and the implications that a chosen security model can have on performance, scalability, and deployment.

Relationship Between IIS and ASP.NET

You should understand the relationship between Internet Information Services (IIS) authentication and the Microsoft® ASP.NET security architecture when designing your application. This will allow you to authenticate your users appropriately and obtain the correct security context within your application. You should note that ASP.NET application security configuration and IIS security configuration are completely independent and can be used independently or in conjunction with each other.

IIS maintains security related configuration settings in the IIS metabase. However, ASP.NET maintains security (and other) configuration settings in XML configuration files. While this generally simplifies the deployment of your application from a security standpoint, the security model adopted by your application will necessitate the correct configuration of both the IIS metabase and your ASP.NET application via its configuration file (Web.config).

The security relationship between IIS and ASP.NET
The security relationship between IIS and ASP.NET

ASP.NET Authentication Providers and IIS Security

ASP.NET implements authentication using authentication providers, which are code modules that verify credentials and implement other security functionality such as cookie generation. ASP.NET supports the following three authentication providers:

  • Forms Authentication. Using this provider causes unauthenticated requests to be redirected to a specified HTML form using client side redirection. The user can then supply logon credentials, and post the form back to the server. If the application authenticates the request (using application-specific logic), ASP.NET issues a cookie that contains the credentials or a key for reacquiring the client identity. Subsequent requests are issued with the cookie in the request headers, which means that subsequent authentications are unnecessary.
  • Passport Authentication. This is a centralized authentication service provided by Microsoft that offers a single logon facility and membership services for participating sites. ASP.NET, in conjunction with the Microsoft® Passport software development kit (SDK), provides similar functionality as Forms Authentication to Passport users.
  • Windows Authentication. This provider utilizes the authentication capabilities of IIS. After IIS completes its authentication, ASP.NET uses the authenticated identity’s token to authorize access.

In addition to authentication, ASP.NET provides an impersonation mechanism to establish the application thread’s security token. Obtaining the correct token relies upon you configuring IIS authentication, ASP.NET authentication providers, and ASP.NET impersonation settings appropriately. This figure the most likely combinations between IIS authentication and ASP.NET providers.

ASP.NET and IIS security settings matrix
ASP.NET and IIS security settings matrix

N-Tier Web Applications using ASP.NET 2.0

11 06 2008

When .NET Framework was first introduced, it provided excellent features that made the construction of ASP.NET applications a breezy experience. Then the next version of .NET Framework (version 2.0) along with SQL Server 2005 builds on the foundation of the previous versions and introduces some new features that can greatly aid in the design and development of N-Tier ASP.NET 2.0 applications.


Designing N-Tier client/server architecture is no less complex than developing two-tier architecture, however the N-Tier architecture, produces a far more flexible and scalable client/server environment. In two-tier architecture, the client and the server are the only layers. In this model, both the presentation layer and the middle layer are handled by the client. N-Tier architecture has a presentation layer and three separate layers – a business logic layer and a data access logic layer and a database layer. The next section discusses each of these layers in detail.

Different Layers of an N-Tier application

In a typical N-Tier environment, the client implements the presentation logic (thin client). The business logic and data access logic are implemented on an application server(s) and the data resides on database server(s). N-tier architecture is typically thus defined by the following layers:

  • Presentation Layer: This is a front-end component, which is responsible for providing portable presentation logic. Since the client is freed of application layer tasks, which eliminates the need for powerful client technology. The presentation logic layer consists of standard ASP.NET web forms, ASP pages, documents, and Windows Forms, etc. This layer works with the results/output of the business logic layer and transforms the results into something usable and readable by the end user.
  • Business Logic Layer: Allows users to share and control business logic by isolating it from the other layers of the application. The business layer functions between the presentation layer and data access logic layers, sending the client’s data requests to the database layer through the data access layer.
  • Data Access Logic Layer: Provides access to the database by executing a set of SQL statements or stored procedures. This is where you will write generic methods to interface with your data. For example, you will write a method for creating and opening a SqlConnection object, create a SqlCommand object for executing a stored procedure, etc. As the name suggests, the data access logic layer contains no business rules or data manipulation/transformation logic. It is merely a reusable interface to the database.
  • Database Layer: Made up of a RDBMS database component such as SQL Server that provides the mechanism to store and retrieve data.

Artificial Intelligence with PHP

23 05 2008

Humans have long been fascinated with Artificial Intelligence. Online artificial intelligence, often called bots, are all measured against the mother of all online intelligence, A.L.I.C.E. Standing for “Artificial Linguistic Internet Computer Entity,” A.L.I.C.E is a chat bot developed in the mid 90s that is capable of holding intelligent conversation, and giving relevant answers.

A.L.I.C.E. and variations of her, respond to the language AIML (Artificial Intelligence Markup Language) to get instruction about how to “think.” There are several implementations of this in languages such as Java, Ruby, Perl, Python, etc, including one in PHP called Program E.

Program E
Program E is a platform for running artificial intelligence robots. It is written in PHP and uses MySQL for its backend database. Program E runs bots that are written in Artificial Intelligence Markup Language or AIML.

Paul Rydell was the original author of Program E. It has since been worked on by Anne Kootstra and Icomsec. You can find Program E on Sourceforge

Try to chat with A. L. I. C. E.

Compiled PHP Script

21 05 2008

PHP script are usually naked, but sometimes we need to capsulating out script for security reason or commercial. There is many way to hide our script, we can use Base 64 Encoding combined with Inflate Compression function and other PHP function that can be reversed. This is the only reason why we need to avoid encrypt the code using PHP function. Every encrypted script need to decrypt first before they run. What should we do is just set a tricky scenario to encrypt and or decrypt back.

I’ve try to using compiled PHP script. I use Bambalam PHP EXE Compiler/Embedder, a light and fast compiler to bundling our PHP script including library, CSS, and external file, except image, sound, and other multimedia file.

There is many way to invoking our compiled script. We can put them into CGI or just execute them using PHP shell execution function (read the PHP Documentation).

Web Server PHP EXE Achitecture

We should design a n-Tier PHP application, then assuming we have a web server with PHP, an application server, and a database server. In this case, an application server is used to put our compiled PHP script and external library. Classes wrote in PHP script that we’ve compiled. Some of our class is used to accessing database server and then compiled class script sent back to web server to displaying the result. So here, a web server is used to show user interface.

I think this way is secure enough to hide our PHP script.

Recognize Text & Objects in Graphical Images with PHP

21 05 2008

An OCR with PHP ? it doesn’t sounds very common topic for PHP developers, but Andrey Kucherenko from Ukraine have made a very interesting project to realize the first phpOCR. His classes can recognize text in monochrome graphical images after a training phase. The training phase is necessary to let the class build recognition data structures from images that have known characters. The training data structures are used during the recognition process to attempt to identify text in real images using the corner algorithm.

PHPOCR have win the PHPClasses innovation awards of march 2006, and it shows the power of what could be implemented with PHP5.

Certain types of applications require reading text from documents that are stored as graphical images. That is the case of scanned documents.

An OCR (Optical Character Recognition) tool can be used to recover the original text that is written in scanned documents. These are sophisticated tools that are trained to recognize text in graphical images.

This class provides a base implementation for an OCR tool. It can be trained to learn how to recognize each letter drawn in an image. Then it can be used to recognize longer texts in real documents.