An Idea can change your life.....

Thursday, January 21, 2010

Effort is important, but knowing where to make an effort makes all the difference!


A giant ship engine failed. The ship's owners tried one expert after another, but none of them could figure but how to fix the engine.




Then they brought in an old man who had been fixing ships since he was a young. He carried a large bag of tools with him, and when he arrived, he immediately went to work. He inspected the engine very carefully, top to bottom.



Two of the ship's owners were there, watching this man, hoping he would know what to do. After looking things over, the old man reached into his bag and pulled out a small hammer. He gently tapped something. Instantly, the engine lurched into life. He carefully put his hammer away. The engine was fixed!



A week later, the owners received a bill from the old man for ten thousand dollars.



"What?!" the owners exclaimed. "He hardly did anything!"



So they wrote the old man a note saying, "Please send us an itemized bill."



The man sent a bill that read:



Tapping with a hammer...... ......... ........ $ 2.00

Knowing where to tap.......... ......... ...... $ 9, 998.00

Sunday, November 29, 2009

Integration Services Videos (SQL Server 2008)

Use Integration Services videos to accomplish the following goals:


* Learn about the product and component technologies.

* See how to do various tasks.

* Discover related help topics that help you expand your knowledge of Integration Services.

http://technet.microsoft.com/en-us/library/dd299421.aspx

SQL Server How Do I Videos How-To Demos

Videos Link

http://technet.microsoft.com/hi-in/sqlserver/dd353197%28en-us%29.aspx

Friday, November 27, 2009

How to create a computed column using SQL Server Management Studio?

How to create a computed column using SQL Server Management Studio?

Take the following steps to create a computed column using SQL Server Management Studio:
  1. Run SQL Server Management Studio from Start > Programs > Microsoft SQL Server 2005 > SQL Server Management Studio.


  2. In the Connect to Server window, click the Connect button.


  3. In the Microsoft SQL Server Management Studio window, double-click the Databases folder.


  4. In the Microsoft SQL Server Management Studio window, double-click the required database. Here, the Axle database is being used.


  5. In the Microsoft SQL Server Management Studio window, double-click the Tables folder.


  6. In the Microsoft SQL Server Management Studio window, right-click the required table and click Modify.


  7. Type the name of the new column. Here, Amount is the new column.


  8. In Column Properties, expand Computed Column Specification. In the Formula box, type the formula. Here, the Price column is multiplied by the Quantity column.


  9. Go to the File menu and click Save Products to save the modifications in the Products table.


What are the conditions under which a function can be schema bound?

What are the conditions under which a function can be schema bound?

A function can be schema bound only if the following conditions are true:
  • The function is a Transact-SQL function.
  • The user-defined functions and the views it references are also schema-bound.
  • The objects that the function references are referenced using a two-part name.
  • The function and the objects it references belong to the same database.
  • The user who executed the CREATE FUNCTION statement has REFERENCES permission on the database objects that the function references.
  • SCHEMABINDING cannot be specified for functions that reference alias data types or CLR functions.

Friday, November 20, 2009

Wednesday, November 18, 2009

Attitude



An old man lived alone in a village.

He wanted to spade his potato garden, but it was very hard work.

His only son, who would have helped him, was in prison.

The old man wrote a letter to his son and mentioned his situation:

Dear Son,

I am feeling pretty bad because it looks like I won't be able to plant my potato garden this year.

I hate to miss doing the garden, because your mother always loved planting time.

I'm just getting too old to be digging up a garden plot.

If you were here, all my troubles would be over.

I know you would dig the plot for me, if you weren't in prison.

Love,

Dad

Shortly the old man received this telegram:

"For Heaven's sake, Dad, don't dig up the garden!! That's where I buried the GUNS!!"

At 4 a.m the next morning, a dozen FBI agents and local police officers showed up and dug up the entire garden without finding any guns.

Confused, the old man wrote another note to his son telling him what happened, and asked him what to do next.

His son's reply was:

"Go ahead and plant your potatoes, Dad.. It's the best I could do for you from here."


Moral:
"NO MATTER WHERE YOU ARE IN THE WORLD,
IF YOU HAVE DECIDED TO DO SOMETHING DEEP FROM YOUR HEART YOU CAN DO IT. IT IS THE THOUGHT THAT MATTERS.. NOT WHERE YOU ARE OR WHERE THE PERSON IS"


Sunday, November 15, 2009

Friday, November 06, 2009

Install multiple versions of IE on your PC


















Install multiple versions of IE on your PC

Ever wanted to test your website in various versions of Internet Explorer?

Every time you install a newer version of Internet Explorer, Windows has a tendency to overwrite previous versions. And generally, that's a good thing. You're missing out on an awful lot if you're using Internet Explorer 3 to browse the web these days. AJAX, Flash, and other newfangled features just aren't going to work as well, or at all.

But if you're a developer and you want to see how your website looks to someone running an ancient browser, you might want to install an old copy of Internet Explorer alongside your IE7. And it turns out that this is completely doable if a little complicated. You need to alter some settings, redirect some DLLs, and rename a few things here and there.

If you have a PC running Windows XP (it doesn't work for Vista) and you want to test your application in multiple versions of Internet Explorer, you need to install this software.











Thursday, November 05, 2009

sql server Xquery Samples

./author

All elements within the current context. Note that this is equivalent to the expression in the next row.

author

All elements within the current context.

first.name

All elements within the current context.

etc....

check below

XPath Examples expressions

XML structure





Key terminology


The material in this section is based on the XML Specification. This is not an exhaustive list of all the constructs which appear in XML; it provides an introduction to the key constructs most often encountered in day-to-day use.

 (Unicode) Character

By definition, an XML document is a string of characters. Almost every legal Unicode character may appear in an XML document.

Processor and Application

Software which processes an XML document. It is expected that a processor works in the service of an application. There are certain very specific requirements about what an XML processor must do and not do, but none as to the behavior of the application. The processor (as the specification calls it) is often referred to colloquially as an XML parser.

Markup and Content

The characters which make up an XML document are divided into markup and content. Markup and content may be distinguished by the application of simple syntactic rules. All strings which constitute markup either begin with the character "<" and end with a ">", or begin with the character "&" and end with a ";". Strings of characters which are not markup are content.

 Tag

A markup construct that begins with "<" and ends with ">". Tags come in three flavors: start-tags, for example
, end-tags, for example
, and empty-element tags, for example .

Element

A logical component of a document which either begins with a start-tag and ends with a matching end-tag, or consists only of an empty-element tag. The characters between the start- and end-tags, if any, are the element's content, and may contain markup, including other elements, which are called child elements. An example of an element is Hello, world.. Another is .

Attribute

A markup construct consisting of a name/value pair that exists within a start-tag or empty-element tag. In this example, the name of the attribute is "number" and the value is "3": Connect A to B. This element has two attributes, src and alt: by Raphael An element must not have two attributes with the same name.

XML Declaration

XML documents may begin by declaring some information about themselves, as in the following example.



Sql Server Sample


Source

Save Web Page as pdf


















Use PDF Download to do whatever you like with PDF files on the Web. Regain control and eliminate browser problems, view PDFs directly in Firefox as HTML, and use the all-new Web-to-PDF toolbar to save and share Web pages as high-quality PDF files.

Install Here

Execise Video DataBase

Execise Video DataBase

Learn Correct  exercise technique

Exercise videos with tips and instructions













To get the maximum results out of any exercise you should use the correct technique. The best way to learn good technique is one on one, but since we can't get to every gym around the world we've got the next best thing, exercise instruction videos and pictures!




Each video is a demonstration of how to do the exercise using correct technique. There is also additional information, tips, pictures and links on the video pages to help you get the best results using the exercise. If you need help with any of these exercises just ask in the forum.
 
Source

Wednesday, November 04, 2009

xquery xpath expressions

XQuery uses XPath  expressions to locate nodes in a document and to navigate from one location to another within a single document or across documents. Navigation paths defined using XPath consist of a sequence of steps separated by /. A single step comprises an axis, a node test, and zero or more step qualifiers.

The axis specifies the direction of movement, relative to the context node. Supported axes in SQL Server 2005 are child, descendant, parent, attribute, self and descendant-or-self.

child : the children of the context node





descendant : all descendants (children, childrens children, ...)




parent : the parent (empty if at the root)




ancestor : all ancestors from the parent to the root




following-sibling : siblings to the right




preceding-sibling : siblings to the left




following : all following nodes in the document, excluding descendants

preceding : all preceding nodes in the document, excluding ancestors

attribute : the attributes of the context node

namespace : namespace declarations in the context node

self : the context node itself

descendant-or-self :  the union of descendant and self


ancestor-or-self : the union of ancestor and self

Create,View,Edit PDF files Online

Edit PDF files with PDFescape - an online, free PDF reader, free PDF editor & free PDF form filler. View PDF documents on the web









Click Here To Use PDFescape Now Free!

(Psst, it's the only free PDF editor & form filler online!)

Sub Query

















The SQL subquery feature lets you use the results of one query as part of another query.

A subquery is a query within a query.



A sub-query is a SQL Server statement embedded inside of another SQL Server statement.

Sub-query execution is dependent upon the nesting level of the query. The execution tree goes from inner-most queries to outer-most queries. The higher nested queries can access the results returned by the lower nested queries.


Paranthesis
  • A sub‐query must be enclosed in the parenthesis
comparison operator
  • A sub‐query must be put in the right hand of the comparison operator
Order By
  • A sub‐query cannot contain an ORDER‐BY clause
Number Of SubQuery's
  • A query can contain more than one sub‐query
Types
  • Sub Query
  • Correlated Sub Query
Results
  • Single Row
  • Multipe Row
  • Multiple Columns

Correlated Sub Query Sample
A correlated sub-query is dependent upon the outer query. The outer query and the sub-query are related typically through a WHERE statement located in the sub-query. The way a correlated sub-query works is when a reference to the outer query is found in the sub-query, the outer query will be executed and the results returned to the sub-query. The sub-query is executed for every row that is selected by the outer query.
____________________________________________________
CREATE TABLE SalesHistory

(
SaleID INT IDENTITY(1,1),
Product VARCHAR(30),
SaleDate SMALLDATETIME,
SalePrice MONEY
)

SELECT SaleDate, Product, SalePrice,
ISNULL(
(
SELECT
SUM(SalePrice)
FROM
SalesHistory sh1
WHERE
Sh1.Product = sh.Product AND
Sh1.SaleID < sh.SaleID
),0) AS RunningTotal
FROM SalesHistory sh
ORDER BY Product, SaleID

____________________________________________________

Saturday, October 31, 2009

Index Seek VS Index scan

SQL Server can use different data access strategies when retrieving rows from the table. The strategy that will be used depends on the columns of the table, the available indexes, the query, the data in the table, and the statistics. There are 7 basic data access strategies.

SQL Server: Scans and seeks


The most primitive operation in SQL Server is retrieving from a table a set of rows that satisfies a given search predicate. This can be achieved using two basic strategies: scans and seeks.

Scan

Scans can be performed on any structure (index or heap). Scanning a table means that SQL Server reads all the rows in the table. Only the rows satisfying the search predicate are returned. Scans imply sequential reads that are usually faster than reading each page individually, but the cost of this operation is proportional to the size of the table.
In indexes, SQL Server uses the pointers to the next page (or previous) for scanning. In a heap, it uses the IAM pages.
The number of logical reads during this operation is the number of pages read during the scan, plus one logical read at each non-leaf level, in case of an index, in order to locate the first row of the table. This operation counts as a scan in the IO statistics.

Seek

Seeks can only be performed on indexes (clustered or nonclustered). A seek is performed when SQL Server can leverage the ordering of the rows in the index to identify a range of rows in the index that contains all the rows satisfying the search predicate.
The search predicate is divided in two parts:
  • The seek predicate, such as all the rows within this range satisfy the seek predicate, and all the rows outside of that range don't. Seek predicates are usually predicates on the leftmost columns of the key of an index.
  • The residual predicate, such as the search predicate is the conjunction of the seek predicate and the residual predicate. The residual predicate is optional.
source

Index Scan retrieves all the rows from the table. Index Seek retrieves selective rows from the table.

SEEK is better then SCAN

But there are few scenarios where SCAN operator perform better then SEEK specially when large number of rows are expected to return by operation.

sample

Friday, October 30, 2009

UPDATE STATISTICS

You can add statistics on columns that don't have statistics in order to boost query performance.

UPDATE STATISTICS updates the indexes on these tables accordingly.

difference between DELETE & TRUNCATE commands

Where Condition
  • Delete Removes the rows from a table based on the condition that we provide with a WHERE clause.








  • Truncate Actually remove all the rows from a table(i.e there is no where condition on this)








Transaction log

Truncate:

  • Is faster and uses fewer system and transaction log resources than DELETE.


  • Deallocates the data pages used to store the table’s data, and only the page deallocations are recorded in the transaction log.


  • directly delete records without entry in transaction log.


  • It Can't be rollbacked
TRUNCATE Can’t be Rolled Back Using Log Files After Transaction Session Is Closed.
But can be rollbacked the following way

____________________________________________________________
 CREATE TABLE dbo.TEST_TRUNCATE (COL1 INT IDENTITY, COL2 NVARCHAR(100));

SET NOCOUNT ON
GO
INSERT INTO dbo.TEST_TRUNCATE (COL2) VALUES ('TEST TRUNCATE');
GO
 BEGIN TRAN
/*Show me the count of the records before truncate*/

SELECT COUNT(*) FROM dbo.TEST_TRUNCATE

TRUNCATE TABLE dbo.TEST_TRUNCATE

/*Show me the count of the records now*/

PRINT 'INSIDE THE TRANSACTION'

SELECT COUNT(*) FROM dbo.TEST_TRUNCATE

/*Rollback now*/

ROLLBACK TRAN

/*Show me the count of the records now*/


PRINT 'OUTSIDE THE TRANSACTION'

SELECT COUNT(*) FROM dbo.TEST_TRUNCATE
______________________________________________________________________________
 
Delete:

  • DELETE removes rows one at a time and records an entry in the transaction log for each deleted row.


  • Can be rollbacked

Identity
Truncate

  •  truncate table the counter used by an identity column for new rows is reset to the seed for the column

Delete

  •  If you want to retain the identity counter, use delete statement instead.


Table referenced by a foreign key constraint

Truncate

  • You cannot use truncate table on a table referenced by a foreign key constraint


  • Because truncate table is not logged, it cannot activate a trigger.

 Delete

  • Delete statement without a where clause works.

Truncate table may not be used on tables participating in an indexed view.

TRUNCATE is DDL Command
DELETE is DML Command

Performance

TRUNCATE TABLE is faster and uses fewer system and transaction log resources. 
Delete Table is slower
The DELETE statement is executed using a row lock, each row in the table is locked for deletion.

Locking
TRUNCATE TABLE always locks the table and page
The DELETE statement is executed using a row lock, each row in the table is locked for deletion


Thursday, October 29, 2009

What's the difference between a primary key and a unique(Candidate) key

uniqueness
Both primary key and unique key enforces uniqueness of the column on which they are defined.
Indexes

  • primary key creates a clustered index on the column
  • unique creates a nonclustered index by default
Nulls
  •  primary key doesn't allow NULLs
  •  but unique key allows one NULL only.
Multiple
  • you can have multiple unique keys in a table
  • can have only one Primary Key
Both of them can be refered as Foreign Key

A foreign key is a column (the child collumn) in a table which has a corresponding relationship and a dependency on another collumn (the parent collumn) that is usually in a different table.