Thursday, June 11, 2009

Performence Issues :Get Worst Performing T-SQL statement

While doing some performence issues in SQL 2005 I came across with this particular Artical ..
http://www.databasejournal.com/features/mssql/article.php/3802936/Finding-the-Worst-Performing-T-SQL-Statements-on-an-Instance.htm

this really helps if u want to know what all the T-SQL statement are worst performer
...............

Enjoy reading

Thursday, March 26, 2009

Normalization In SQL

What is Normalization?Normalization is the process of efficiently organizing data in a database. There are two goals of the normalization process: eliminating redundant data (for example, storing the same data in more than one table) and ensuring data dependencies make sense (only storing related data in a table). Both of these are worthy goals as they reduce the amount of space a database consumes and ensure that data is logically stored. The Normal FormsThe database community has developed a series of guidelines for ensuring that databases are normalized. These are referred to as normal forms and are numbered from one (the lowest form of normalization, referred to as first normal form or 1NF) through five (fifth normal form or 5NF). In practical applications, you'll often see 1NF, 2NF, and 3NF along with the occasional 4NF. Fifth normal form is very rarely seen and won't be discussed in this article.
Before we begin our discussion of the normal forms, it's important to point out that they are guidelines and guidelines only. Occasionally, it becomes necessary to stray from them to meet practical business requirements. However, when variations take place, it's extremely important to evaluate any possible ramifications they could have on your system and account for possible inconsistencies. That said, let's explore the normal forms. First Normal Form (1NF)First normal form (1NF) sets the very basic rules for an organized database: Eliminate duplicative columns from the same table. Create separate tables for each group of related data and identify each row with a unique column or set of columns (the primary key). Second Normal Form (2NF)Second normal form (2NF) further addresses the concept of removing duplicative data: Meet all the requirements of the first normal form. Remove subsets of data that apply to multiple rows of a table and place them in separate tables. Create relationships between these new tables and their predecessors through the use of foreign keys. Third Normal Form (3NF)Third normal form (3NF) goes one large step further: Meet all the requirements of the second normal form. Remove columns that are not dependent upon the primary key. Fourth Normal Form (4NF)Finally, fourth normal form (4NF) has one additional requirement: Meet all the requirements of the third normal form. A relation is in 4NF if it has no multi-valued dependencies.

Saturday, March 21, 2009

System Sp's Used in SQL server

SP's are Precompiled T-SQL statement that are stored on the server .SQL server supplies a group pf SP's collectively called system SP.By using these SP's we can easily and quickly access,update, andmaintain inforamtion that is stored in sytem tables.These stored Procedure Start with sp_
Few of them are as fallows, these can be very useful for getting information while working with SQL server.
1)sp_help:This sp is used to get information about a DBobject which is any object listed in sysobject table or user defined datatype
i)sp_help give information about the object of current DB
ii)in case no parameter it gives information about all the objects in current DB.
syntax: sp_help objname
2)sp_helpDB:This gives information about a specified DB or all theDB's Present in the server
syntax: sp_helpdb objname
in case no parameter it gives information about all the DB's
3)sp_helpSql:very useful sp while working on sql ,it give u help on some topic in otherwords it can give you T-sql statement of some topic e.g. datatype,expression or text function
i) you must include quotation marks around topic parameter
ii)you can enter just few letters of a particular topic to identify it then help on the specified topic is displayed.
syntax: sp_helpsql 'create tablename'
4)sp_who:This reports information about a specific use,a specified SQL server process,all currently running process or all active process
This can be very useful while troubleshooting sql server or when u are facing performence issues with server.
syntax: sp_who

Thursday, March 19, 2009

Fetching Top n data from SQL Server table

Here is the way::
Select top n columnname from tblname
if you have 2 data same the use With tie
Select top n with tie colname from tblname
order by colname

Note : OrderBy is required for with tie

Writing JavaScript In Server Side

Hi This is the way we can write JavaScript In Server Side