Tuesday, July 31, 2007
Types of constraints
Primary key
This constraint is used to guarantee that a column or set of columns on a table contain unique values for every record in the given table. This lets you ensure data integrity by always being able to uniquely identify the record in the table.
A table can have only one primary key constraint defined on it, and the rows in the primary key columns cannot contain null values. A primary key constraint can be defined when a table is created, or it can be added later.
This script creates a primary key constraint on a single field when the table is created:
IF OBJECT_ID('SalesHistory')>0
DROP TABLE SalesHistory;
GO
CREATE TABLE [dbo].[SalesHistory](
[SaleID] [int] IDENTITY(1,1) NOT NULL PRIMARY KEY,
[Product] [char](150) NULL,
[SaleDate] [datetime] NULL,
[SalePrice] [money] NULL
)
GO
The followings script creates the primary key constraint when the table is created. This method allows you to define a name for the constraint and to create the constraint on multiple columns if necessary.
IF OBJECT_ID('SalesHistory')>0
DROP TABLE SalesHistory;
GO
CREATE TABLE [dbo].[SalesHistory](
[SaleID] [int] IDENTITY(1,1) NOT NULL,
[Product] [char](150) NULL,
[SaleDate] [datetime] NULL,
[SalePrice] [money] NULL,
CONSTRAINT pk_SaleID PRIMARY KEY (SaleID)
)
GO
This script creates the primary key constraint on the table after it is created:
IF OBJECT_ID('SalesHistory')>0
DROP TABLE SalesHistory;
GO
CREATE TABLE [dbo].[SalesHistory](
[SaleID] [int] IDENTITY(1,1) NOT NULL,
[Product] [char](150) NULL,
[SaleDate] [datetime] NULL,
[SalePrice] [money] NULL
)
GO
ALTER TABLE SalesHistory
ADD CONSTRAINT pk_SaleID PRIMARY KEY (SaleID)
GO
Foreign key
This constraint limits the values of columns in one table based upon the values of columns in another table. This link between the two tables requires the use of a "lookup table," which contains the accepted list of values; this list must contain a unique or primary key constraint. After the constraint is established between the two tables, any data modifications to the fields defined in the constraint on the foreign key table will cause a validation to ensure that the data being updated or inserted is contained in the lookup table.
The previous script contains the WITH NOCHECK clause. I use it so that any existing values in the table are not considered when the constraint is added. Any records in the table that violate the newly added constraint will be ignored so that the constraint is created. The constraint will only be applicable to new records entered into the SalesHistory table.
Unique
This constraint guarantees that the values in a column or set of columns are unique. Unique and primary key constraints are somewhat similar because each provide a guarantee for uniqueness for a column or set of columns. A primary key constraint automatically has a unique constraint defined on it.
There are two differences between the constraints: (1) You may have only one primary key constraint per table, yet you may have many unique constraints per table; (2) A primary key constraint will not allow null values but a unique constraint will (although it will only allow one null value per field).
This script creates a unique constraint on the SaleID column when the table is created:
IF OBJECT_ID('SalesHistory')>0
DROP TABLE SalesHistory;
GO
CREATE TABLE [dbo].[SalesHistory](
[SaleID] [int] NOT NULL UNIQUE,
[Product] [char](150) NULL,
[SaleDate] [datetime] NULL,
[SalePrice] [money] NULL
)
GO
The following script creates a unique constraint on the table at creation, and it allows for constraint naming and for defining the unique constraint on multiple columns if necessary.
IF OBJECT_ID('SalesHistory')>0
DROP TABLE SalesHistory;
GO
CREATE TABLE [dbo].[SalesHistory](
[SaleID] [int] NOT NULL,
[Product] [char](150) NULL,
[SaleDate] [datetime] NULL,
[SalePrice] [money] NULL,
CONSTRAINT uc_SaleID UNIQUE (SaleID)
)
GO
This script creates the unique constraint on the SalesHistory table by altering the table after it has been created:
IF OBJECT_ID('SalesHistory')>0
DROP TABLE SalesHistory;
GO
CREATE TABLE [dbo].[SalesHistory](
[SaleID] [int] NOT NULL,
[Product] [char](150) NULL,
[SaleDate] [datetime] NULL,
[SalePrice] [money] NULL
)
GO
ALTER TABLE SalesHistory
ADD CONSTRAINT uc_SaleID UNIQUE(SaleID)
GO
Check
This constraint limits the value range, or domain, in a column. Check constraints check the acceptable values against a logical expression defined in the constraint. These constraints are similar to foreign key constraints in that they both govern the acceptable values for a column or set of columns in a given row in a table. You can create a check constraint at the column or table level. A check constraint on a single column allows only certain values for those columns, while a table check constraint can limit values in certain columns based on values in other fields in the row.
The following script creates a check constraint on the SalePrice column in the SalesHistory table, limiting entries where the SalePrice must be greater than 4. Any attempt to enter a record with the SalePrice present and less than 4 will result in an error.
IF OBJECT_ID('SalesHistory')>0
DROP TABLE SalesHistory;
GO
CREATE TABLE [dbo].[SalesHistory](
[SaleID] [int] NOT NULL,
[Product] [char](150) NULL,
[SaleDate] [datetime] NULL,
[SalePrice] [money] NULL CHECK (SalePrice > 4)
)
GO
Monday, July 23, 2007
SQL Server 2005 Samples (1)
/* Example for PRINT */
PRINT 'sample'
Go

/* Example for SELECT */
SELECT 'book', 200;
GO

SELECT 'book' as material, 200 as items;
GO

Variables and Data Types
/*Example for Declare, initialize, display value of a Variable */
DECLARE @varText INT;
SET @varText = 10;
SELECT @varText as varText;
GO

/*Boolean Variable. you can use the BIT or bit keyword.*/
/* initialize 0 -> false or Any number -> true */
DECLARE @varText BIT;
set @varText = 0;
SELECT @varText as varText;
GO

/* Decimal variable */
/* (either decimal or numeric would produce the same effect in SQL Server */
DECLARE @Distance DECIMAL;
SET @Distance = 27.99;
PRINT @Distance;
GO

/* Floating point */
DECLARE @Distance FLOAT;
SET @Distance = 648.16;
PRINT @Distance;
GO

/* Money Variable */
DECLARE @YearlyIncome Money;
SET @YearlyIncome = 48500.15;
SELECT @YearlyIncome AS [Yearly Income];
GO

/* DATETIME Variable */
DECLARE @IndependenceDay DATETIME;
SET @IndependenceDay = '01/01/1960';
SELECT @IndependenceDay AS [Independence Day];
GO

/*Time*/
DECLARE @ArrivalTime datetime;
SET @ArrivalTime = '18:22';
SELECT @ArrivalTime as [Arrival Time];
GO

/*CHAR Variable*/
DECLARE @Gender CHAR, @LeftMostChar CHAR;
SET @GENDER = 'M';
SET @LeftMostChar = 'Male';
SELECT @Gender as Gender, @LeftMostChar as LeftMostChar;
GO

SQL Expressions
/*IF Condition Statement*/
DECLARE @bool BIT;
SET @bool = 0;
IF @bool <> 0
PRINT 'bool value is True';
ELSE
PRINT 'bool value is False';
GO

/*CASE...WHEN...THEN */
DECLARE @CharGender Char(1), @Gender Varchar(20);
SET @CharGender = 'M';
SET @Gender =
CASE @CharGender
WHEN 'm' THEN 'Male'
WHEN 'M' THEN 'Male'
WHEN 'f' THEN 'Female'
WHEN 'F' THEN 'Female'
ELSE 'Unknown'
END;
SELECT @Gender as Gender
GO

/*WHILE Condition Statement*/
DECLARE @Number As int;
SET @Number = 3;
WHILE @Number < style="color: rgb(51, 51, 255);">BEGIN
SELECT @Number as Number;
SET @Number = @Number + 1;
END;
GO

Functions
/* Create Function */
CREATE FUNCTION addition(@a INT, @b INT)
RETURNS INT
AS
BEGIN
DECLARE @result INT;
SET @result = @a + @b;
RETURN @result;
END;
GO
/* Call Function ------*/
DECLARE @Nbr1 INT,
@Nbr2 INT
SET @Nbr1 = 4268
SET @Nbr2 = 26
SELECT @Nbr1 as First,
@Nbr2 as Second,
user.addition(@Nbr1, @Nbr2) as Result;
GO
Built-in Functions
/* Casting a Value */
DECLARE @stringV VARCHAR(10), @intV INT
SET @stringV = '10';
SET @intV = CAST(@stringV as INT);
SELECT @intV as Result
GO
/* Converting a Value */
/* Casting a Value */
DECLARE @stringV VARCHAR(10), @intV INT, @result INT
SET @stringV = '6';
SET @intV = CAST(@stringV as INT);
SET @result = @intV + @intV;
PRINT 'Result :' + CONVERT(VARCHAR(10), @result, 10);
GO

/* The Length of a String */
DECLARE @stringV varchar(10), @result INT
SET @stringV = 'ABCDEF';
SET @result = LEN(@stringV);
PRINT 'Result :' + CONVERT(VARCHAR(10), @result, 10);
GO
/* Date and Time Based Functions*/
Type of Value | Abbreviation | As a result |
Year | yy | The function will return the number of years that have elapsed between the start and the end dates |
yyyy | ||
quarter | q | The function will return the number of quarters of a year that have elapsed between the start and the end dates |
Month | m | The function will return the number of months that have elapsed between the start and the end dates |
mm | ||
dayofyear | y | The function will return the number of days of a year that have elapsed between the start and the end dates |
dy | ||
Day | d | The function will return the number of days that have elapsed between the start and the end dates |
dd | ||
Week | wk | The function will return the number of weeks that have elapsed between the start and the end dates |
ww | ||
Hour | hh | The function will return the number of hours that have elapsed between the start and the end times or dates |
minute | n | The function will return the number of minutes that have elapsed between the start and the end times or dates |
mi | ||
second | s | The function will return the number of seconds that have elapsed between the start and the end times or dates |
ss | ||
millisecond | ms | The function will return the number of milliseconds that have elapsed between the start and the end times or dates |
/* The Current System Date and/or Time */
DECLARE @currentDateTime DATETIME
SET @currentDateTime = GETDATE();
SELECT @currentDateTime AS CurrentDateTime;
GO
/*Date/Time Addition
Format :- DATEADD(TypeOfValue, ValueToAdd, DateOrTimeReferenced)*/
DECLARE @Anniversary As DateTime;
SET @Anniversary = '2002/10/02';
SELECT DATEADD(yy, 4, @Anniversary) AS Anniversary;
GO
/*Date/Time Addition
Format :- DATEDIFF(TypeOfValue, StartDate, EndDate) */
DECLARE @DateHired As DateTime, @CurrentDate As DateTime;
SET @DateHired = '2006/10/12';
SET @CurrentDate = GETDATE();
SELECT DATEDIFF(mm, @DateHired, @CurrentDate)
AS [Current Experience], DATEDIFF(dd, @DateHired, @CurrentDate) as Days;
GO
Tuesday, July 17, 2007
Windows Server 2008

Just announced at the Worldwide Partner Conference, Windows Server 2008 will be launched jointly with Visual Studio 2008 and SQL Server 2008 on Feb. 27, 2008, in Los Angeles. As the most important enterprise launch in company history, this will kick off a "launch wave" of hundreds of worldwide events hosted by Microsoft.
• Built for the Web
Simplify Web server management with Internet Information Services 7.0, which is a powerful Web platform for applications and services. This modular platform provides a simplified, task-based management interface, greater cross-site control, security enhancements, and integrated health management for Web Services.
Internet Information Server (IIS) 7 and .NET Framework 3.0 provide a comprehensive platform for building applications that connect users to each other and to their data, enabling them to visualize, share, and act on information.
• Virtualization
Virtualize multiple operating systems – Windows, Linux and others – on a single server. With virtualization built into the operating system and with simpler, more flexible licensing policies, it’s now easier than ever to take advantage of all the benefits and cost savings of virtualization.
Windows Server 2008 provides you with the flexibility to create an agile and dynamic datacenter to meet your changing business needs.
Terminal Services Gateway and Terminal Services RemoteApp are designed for easy remote access and application integration with the local desktop, enabling secure and seamless application deployment without the need for a VPN.
• Security
Windows Server 2008 is the most secure Windows Server ever. Its hardened operating system and security innovations, including Network Access Protection, Federated Rights Management, and Read-Only Domain Controller, provide unprecedented levels of protection for your network, your data, and your business.
Windows Server 2008 helps protect against failure and intrusion for servers, networks, data, and user accounts.
Network Access Protection gives you the power to isolate computers that don’t comply with your organization's security policies, and provides network restriction, remediation, and ongoing compliance checking.
Federated Rights Management Services provides persistent protection for sensitive data; helps reduce risks and enables compliance; and provides a platform for comprehensive information protection.
Read-Only Domain Controller allows you to deploy Active Directory Domain Services while restricting replication of the full Active Directory database, to better protect against server theft or compromise.
• A Solid Foundation for Your Business Workloads
Windows Server 2008 is the most flexible and robust Windows Server operating system to date. With new technologies and features such as Server Core, PowerShell, Windows Deployment Services, and enhanced networking and clustering technologies, Windows Server 2008 provides you the most versatile and reliable Windows platform for all of your workload and application requirements.
Server Manager accelerates server setup and configuration, and simplifies ongoing management of server roles via a unified management console.
Windows PowerShell is a new command-line shell with more than 130 tools and an integrated scripting language that enables an administrator to automate routine system administration tasks, especially across multiple servers.
Server Core is a new installation option for selected roles that includes only the necessary components and subsystems without a graphical user interface, to provide a highly available server that requires fewer updates and less servicing.
Monday, July 16, 2007
Microsoft Visual Studio 2008

Visual Studio Product Roadmap
Microsoft® Visual Studio® 2008 (formerly known as, Microsoft® Visual Studio® code name “Orcas”) delivers on Microsoft’s vision of smart client applications by enabling developers to rapidly create connected applications that deliver the highest quality rich user experiences. With Visual Studio 2008, organizations will find it easier than ever before to capture and analyze information so that they can make effective business decisions. Visual Studio 2008 enables any size organization to rapidly create more secure, manageable & reliable applications that take advantage of Windows Vista and the 2007 Office system.
Visual Studio 2008 delivers key advances for developers in three primary pillars:
Improve Developer Productivity
In Visual Studio 2008, developer productivity doesn’t end with the code editor and wizards. By extending this concept to application architectures and the underlying platform, Visual Studio 2008 delivers not only a productive development tool but also enables developers to tackle new business problems while decreasing the total cost of solution construction. In Visual Studio 2008, developers, designers and database professionals will see new tools and frameworks become available to simplify their tasks.
Manage the IT Life Cycle
Visual Studio 2008 enhances the end-to-end value of Visual Studio Team System by increasing its role-based coverage and delivering enhanced traceability throughout the software development life cycle. With deep integration across roles in the software life cycle and the Team Foundation Server, Team System enables customers to amplify the impact of their teams and improve software quality.
Employ the Latest Technologies
As users look for new ways of comprehending and retaining information developers must still grapple with basic desktop and application security. Visual Studio, Windows Vista and the 2007 Office system enable you to deliver a safe, robust and compelling user experience in any type of application.
Visual Studio 2008 achieves these key advances through a wide array of innovative product improvements, such as:
Handle Data More Smoothly
With the introduction for Language Integrated Query (LINQ) and improvements to ADO.NET, developers can now deal with data using a consistent programmatic way and with new design surfaces and support for the occasionally connected design pattern.
Enable New Web Experiences
Beyond the secure, reliable & extensible infrastructure of IIS, developers can easily create Web applications with more interactive, more responsive and more efficient client-side execution using the seamless integration and familiar programming model of ASP.NET AJAX and other extensions & enhancements.
Improve Application Life-cycle Management (ALM)
Visual Studio 2008 provides great support for not only managing the entire software development life cycle, but also the critical interaction with the final end users and managers of an enterprise application.
Target Windows Vista and .NET Framework 3.0 Development
Developers will be easily able to leverage new platform technologies and deliver more compelling applications to their customers by effortlessly incorporating new Windows Presentation Foundation (WPF) features into both existing Windows Forms applications and new applications.
Create Microsoft Office Applications
Visual Studio Tools for Office is now fully integrated into Visual Studio 2008 Professional Edition enables developers to customize any Office application, from Outlook to PowerPoint, to improve end user productivity and significantly improving deployment.
Microsoft SQL Server 2008

SQL Server 2008, the next release of Microsoft SQL Server, provides a comprehensive data platform that is more secure, reliable, manageable and scalable for your mission critical applications, while enabling developers to create new applications that can store and consume any type of data on any device, and enabling all your users to make informed decisions with relevant insights.
SQL Server 2008 will provide a more secure, reliable and manageable enterprise data platform.
- Provides a scalable and reliable platform with advanced security technology for even the most demanding applications.
- Reduces the time and cost of managing data infrastructure with innovative policy based management.
SQL Server 2008 will enable developers and administrators to save time by allowing them to store and consume any type of data from XML to documents.
- Manages any type of data from relational data to documents, geographic information and XML.
- Offers a consistent set of services and tools across data types.
SQL Server 2008 provides a more scalable infrastructure that enables IT to drive business intelligence throughout the organization.
- Brings powerful BI capabilities and valuable data even closer to every user.
- Empower users to easily consume information due to increased integration with Microsoft Office.
- Provides reports of any size or complexity internally within organizations and externally to partners and suppliers.
- Integrates all relevant data into a scalable and comprehensive data warehouse platform.
SQL Server 2008 along with the .NET Framework will accelerate the development of the next generation of applications.
- Provides an integrated development environment with Microsoft Visual Studio and .NET Framework that will accelerate development of new applications with a higher level of data abstraction.
- Enables developers to synchronize data from virtually any device to the central data store.
Thursday, July 12, 2007
Super Star Rajinikanth




Rajinikanth was born on December 12 1949 in Karnataka, India. He was the fourth child to his parents Ramabai and Ramoji Rao Gaekwad. His original name was Shivaji Rao Gaekwad. He lost his mother at the age of five. He had his schooling at the Acharya Patasala in Bangalore and then at the Vivekananda Balak Sangh, a unit of the Ramakrishna Mission. His mother tongue is Marathi, though he has not done any movie in it.
Before starting his career in the film industry, he had to take up all sorts of odd jobs. He served as a bus conductor for Karnataka state transport corporation in Bangalore. It was during this time that he nurtured his acting interests by performing in various stage plays.
The evergreen unique actor and the Superstar of Tamil industry, Rajinikanth was introduced by the renowned director, K.Balachandar in the movie Aboorva raagangal as a co-artist. It's been 25 years, believe it or not, since the Super Star made his debut with an inconsequential role in a Tamil film. From villain and antihero to blockbuster supernova, the gifted actor has made the most of every outing. And he's deserved every bit of the success.
Wednesday, July 11, 2007
Bill Gates


Chairman, Microsoft Corp.
William (Bill) H. Gates is chairman of Microsoft Corporation, the worldwide leader in software, services and solutions that help people and businesses realize their full potential. Microsoft had revenues of US$44.28 billion for the fiscal year ending June 2006, and employs more than 71,000 people in 103 countries and regions.
On June 15, 2006, Microsoft announced that effective July 2008 Gates will transition out of a day-to-day role in the company to spend more time on his global health and education work at the Bill & Melinda Gates Foundation. After July 2008 Gates will continue to serve as Microsoft’s chairman and an advisor on key development projects. The two-year transition process is to ensure that there is a smooth and orderly transfer of Gates’ daily responsibilities. Effective June 2006, Ray Ozzie has assumed Gates’ previous title as chief software architect and is working side by side with Gates on all technical architecture and product oversight responsibilities at Microsoft. Craig Mundie has assumed the new title of chief research and strategy officer at Microsoft and is working closely with Gates to assume his responsibility for the company’s research and incubation efforts.
Born on Oct. 28, 1955, Gates grew up in Seattle with his two sisters. Their father, William H. Gates II, is a Seattle attorney. Their late mother, Mary Gates, was a schoolteacher, University of Washington regent, and chairwoman of United Way International.
Gates attended public elementary school and the private Lakeside School. There, he discovered his interest in software and began programming computers at age 13.
In 1973, Gates entered Harvard University as a freshman, where he lived down the hall from Steve Ballmer, now Microsoft's chief executive officer. While at Harvard, Gates developed a version of the programming language BASIC for the first microcomputer - the MITS Altair.
In his junior year, Gates left Harvard to devote his energies to Microsoft, a company he had begun in 1975 with his childhood friend Paul Allen. Guided by a belief that the computer would be a valuable tool on every office desktop and in every home, they began developing software for personal computers. Gates' foresight and his vision for personal computing have been central to the success of Microsoft and the software industry.
Under Gates' leadership, Microsoft's mission has been to continually advance and improve software technology, and to make it easier, more cost-effective and more enjoyable for people to use computers. The company is committed to a long-term view, reflected in its investment of approximately $6.2 billion on research and development in the 2005 fiscal year.
In 1999, Gates wrote Business @ the Speed of Thought, a book that shows how computer technology can solve business problems in fundamentally new ways. The book was published in 25 languages and is available in more than 60 countries. Business @ the Speed of Thought has received wide critical acclaim, and was listed on the best-seller lists of the New York Times, USA Today, the Wall Street Journal and Amazon.com. Gates' previous book, The Road Ahead, published in 1995, held the No. 1 spot on the New York Times' bestseller list for seven weeks.
Gates has donated the proceeds of both books to non-profit organizations that support the use of technology in education and skills development.
In addition to his love of computers and software, Gates founded Corbis, which is developing one of the world's largest resources of visual information - a comprehensive digital archive of art and photography from public and private collections around the globe. He is also a member of the board of directors of Berkshire Hathaway Inc., which invests in companies engaged in diverse business activities.
Philanthropy is also important to Gates. He and his wife, Melinda, have endowed a foundation with more than $28.8 billion (as of January 2005) to support philanthropic initiatives in the areas of global health and learning, with the hope that in the 21st century, advances in these critical areas will be available for all people. The Bill and Melinda Gates Foundation has committed more than $3.6 billion to organizations working in global health; more than $2 billion to improve learning opportunities, including the Gates Library Initiative to bring computers, Internet Access and training to public libraries in low-income communities in the United States and Canada; more than $477 million to community projects in the Pacific Northwest; and more than $488 million to special projects and annual giving campaigns.
Gates was married on Jan. 1, 1994, to Melinda French Gates. They have three children. Gates is an avid reader, and enjoys playing golf and bridge.