Tuesday, April 19, 2011

SQL Server 2005 Mainstream support Ended


The Microsoft SQL Server 2005 Mainstream support has ended by 12-April-2011. Therfore the certification exams associated with the product will also be expired. So please note that all the Microsoft SQL Server 2005 exams are scheduled to retire on June 30, 2011.



Choose from the following three MCITP certifications on SQL Server 2005.

MCITP certification
Prerequisite MCTS certification
Exam(s)
MCITP: Database Administrator
MCTS: SQL Server 2005
Exam 70-443:* PRO: Designing a Database Server Infrastructure by Using Microsoft SQL Server 2005
and
Exam 70-444:* PRO: Optimizing and Maintaining a Database Administration Solution by Using Microsoft SQL Server 2005
MCITP: Database Developer
MCTS: SQL Server 2005
Exam 70-441:* PRO: Designing Database Solutions by Using Microsoft SQL Server 2005
and
Exam 70-442:* PRO: Designing and Optimizing Data Access by Using Microsoft SQL Server 2005
MCITP: Business Intelligence Developer
MCTS: SQL Server 2005, Business Intelligence Development and Maintenance
Exam 70-446:* PRO: Designing a Business Intelligence Solution by Using Microsoft SQL Server 2005
*This exam is scheduled to retire on June 30, 2011.


Buy a Microsoft Certification Pack with Second Shots and save up to 20%

http://ads.bluelithium.com/pixel?id=741697&t=2http://bp.specificclick.net/?pixid=99012333Microsoft Certification Exam Packs provide large discounts plus a Second Shot for every exam in the pack. The Second Shot offer allows you to retake an exam if you do not pass it the first time.

New: If you obtained your Exam Pack voucher code before January 1, 2011, you have until June 30, 2011, to complete your exams and any retakes. If you obtain your Exam Pack voucher code on or after January 1, 2011, you have until June 30, 2011, to schedule and take your first exam. 

You can find the benefits of doing certification from Microsoft’s web site. You can find the salary ranges in INR by job for employees with MCTS – SQL Server 2005 certification.



Those who have are willing to have SQL Server 2005 certification should consider to take the exam before 30-June-2011 followed by a upgrade exam for SQL Server 2008.

Error Handling in SQL Server 2005


TRY…CATCH construct is used for error handling in side T-SQL code. A TRY…CATCH construct consists of 2 blocks. One is TRY block that is immediately followed by a CATCH block. TRY…CATCH construct can be nested. When an error condition is identified in TRY block, the control is immediately transferred to CATCH block where the error can be handled.

The following code represents a basic TRY…CATCH construct.

BEGIN TRY
SELECT 1/0;
END TRY

BEGIN CATCH
      SELECT ERROR_MESSAGE();
END CATCH

Error Functions:

The following error functions can be used inside a TRY…CATCH construct to get the information about the error that is occurred.

ERROR_NUMBER() returns the error number.
ERROR_MESSAGE() returns the complete text of the error message. The text includes the values supplied for any substitutable parameters such as lengths, object names, or times.
ERROR_SEVERITY() returns the error severity.
ERROR_STATE() returns the error state number.
ERROR_LINE() returns the line number inside the routine that caused the error.
ERROR_PROCEDURE() returns the name of the stored procedure or trigger where the error occurred.


TRY…CATCH with RAISERROR

RAISERROR can be used inside a TRY…CATCH construct for error handling. RAISERROR generates error message using user defined messages that is stored inside sys.messages catalog view or build a message dynamically.

The following code returns an error message and the WITH LOG statement causes the error to be logged into windows application log. Using event viewer, you can view the log.

BEGIN TRY
    RAISERROR ('Error raised in TRY block.', 16,10) WITH LOG;
END TRY
BEGIN CATCH
    SELECT Error_Message() as Message_text,
               Error_Severity() as Severity,
               Error_State() as State
END CATCH

Questions:
1. What types of error cannot be handled by TRY…CATCH construct. Choose all correct answers from the following:

a. All DDL statement errors

b. All DML statement errors

c. Divide by Zero error

d. Syntax errors that prevent a batch from executing.

Answers:

1. d.

Thursday, December 23, 2010

SQL Scripts Manager a free tool from Red Gate



Red Gate's new "SQL Scripts Manager" is available for free download. 


This tool contains over 28 scripts written by expert DBAs, SQL Server MVPs, and Red Gate's SQL developers., to help you streamline monotonous administration and scripting tasks. 


You can easily customize this tool for using your own script.


You can view the description about scripts used, script source and author information.


Download SQL Scripts Manager now and start benefitting from the collective wisdom of these experts – and sharing your own scripts with the SQL Server community – today.


This will be really a very useful and handy tool for DBAs.










The following are the scripts available:

  1. SQL FileGroup SpaceUsed  
  2. Monitoring Plan Cache    
  3. CPU Utilization    
  4. IO Stalls    
  5. Top Resource Waits    
  6. Buffer Cache Hit Ratio    
  7. Object Read Write Ratio    
  8. Top Cpu Intensive Queries    
  9. Database Backup    
  10. Database Integrity Check    
  11. Deploy Maintenance Scripts    
  12. Index Maintenance    
  13. CallProc Template    
  14. InsertInto Template    
  15. Select From Table    
  16. Table Valued Function Template    
  17. Update Templates    
  18. Ping    
  19. Full And Log Backups In Past X Days    
  20. Last Good Database Backup    
  21. Read Error Logs The DBA Way    
  22. Blocking Transactions    
  23. Investigating Fragmented Indexes    
  24. Who Is Running What    
  25. Get Hit Ratio  
  26. Get Partitioned DBs  
  27. Get Tables With No Clustered Index
  28. Get Version And Uptime  

Tuesday, December 21, 2010

SQL Server 2005 Top 10 Features for Database Administration

Feature
Description
Database Mirroring
Extend log shipping capabilities with the database mirroring solution. You will be able to use database mirroring to enhance availability of your SQL Server systems by setting up automatic failover to a standby server.
Online Restore
With SQL Server 2005, database administrators are able to perform a restore operation while an instance of SQL Server is running. Online restore improves the availability of SQL Server because only the data being restored is unavailable; the rest of the database remains online and available.
Online Indexing Operations
The online index option allows concurrent modifications (updates, deletes, and inserts) to the underlying table or clustered index data and any associated indexes during index data definition language (DDL) execution. For example, while a clustered index is being rebuilt, you can continue to make updates to the underlying data and perform queries against the data.
Fast Recovery
A new faster recovery option improves availability of SQL Server databases. Administrators can reconnect to a recovering database after the transaction log has been rolled forward.
Standards-based Information Access
Any object, data source, or business intelligence component can be exposed using standards-based protocols such as SOAP and HTTP—eliminating the need for a middle-tier listener, such as IIS, to access a Web services interface that is exposed by SQL Server 2005.
SQL Server Management Studio
SQL Server 2005 includes SQL Server Management Studio, a new integrated suite of management tools with the functionality to develop, deploy, and troubleshoot SQL Server databases, as well as enhancements to previous functionality.
Dedicated Administrator Connection
SQL Server 2005 provides a dedicated administrator connection that administrators can use to access a running server even if the server is locked or otherwise unavailable. This capability enables administrators to troubleshoot problems on a server by executing diagnostic functions or Transact-SQL statements.
Snapshot Isolation
Snapshot Isolation (SI) level is provided at the database level. With SI, users can access the last committed row using a transitionally consistent view of the database. This capability provides greater scalability.
Data Partitioning
Data partitioning is enhanced with native table and index partitioning that enables efficient manageability of large tables and indexes.
Replication Enhancements
For distributed databases, SQL Server 2005 provides comprehensive schema change (DDL) replication, next-generation monitoring capabilities, built in replication from Oracle to SQL Server, merge replication over https, and significant merge replication scalability and performance improvements. Additionally, the peer-to-peer transactional replication feature improves support for data scale out using replication.

SQL Server 2005 Top 10 Features for Development

Feature
Description
Hosted CommonLanguage Runtime
With SQL Server 2005 developers can create database objects using familiar languages such as Microsoft Visual C# .NET and Microsoft Visual Basic .NET. Developers can also create two new objects—user-defined types and aggregates.
Native XML Support
Native XML data can be stored, queried, and indexed in a SQL Server database—allowing developers to build new classes of connected applications around Web services and across any platform or device.
ADO.NET version 2.0
From new support for SQL Types to Multiple Active Result Sets (MARS), ADO.NET in SQL Server 2005 evolves dataset access and manipulation to achieve greater scalability and flexibility.
Security Enhancements
The security model in SQL Server 2005 separate users from objects, provides fine-grain access, and enables greater control of data access. Additionally, all system tables are implemented as views, providing more control over database system objects.
Transact-SQL Enhancements
SQL Server 2005 provides new language capabilities for developing scalable database applications. These enhancements include error handling, recursive query capabilities, relational operator PIVOT, APPLY, ROW_NUMBER and other row ranking functions, and more.
Reliable Messaging for Asynchronous Applications
Service Broker is a robust messaging infrastructure that provides reliable transactional delivery of critical messages between servers—with the scalable high-performance that is expected with asynchronous queuing.
Visual Studio Integration
Tight integration with Microsoft Visual Studio and the .NET Framework streamlines development and debugging of data-driven applications. Developers can build database objects, such as stored procedures, using any .NET language and can seamlessly debug across .NET and Transact-SQL (TSQL) languages.
Web Services
With SQL Server 2005 developers can develop Web services in the database tier, making SQL Server a hypertext transfer protocol (HTTP) listener and providing a new type of data access capability for Web services-centric applications.
Embedded Reports
Use client-side reporting controls to embed real-time reports into an application at design time.
Full-Text Search Enhancements
SQL Server 2005 supports rich, full-text search applications. Cataloging capabilities provide greater flexibility over what is cataloged. Query performance and scalability have been improved dramatically, and new management tools provide greater insight into the full-text implementation.

Monday, December 13, 2010

Questions on SQL JOINS

A join will allow us to view data from related tables in a single result set.

INNER JOIN:
  • In an inner join, Only rows with values satisfying the join condition in the common column are displayed.
  • It is default join. So 'INNER' keyword can be ignored.

OUTER JOIN:
  • In an outer join, rows are returned even when there are no matches through the JOIN criteria on the second table.
  • Outer join is of three types: Left, Right, Full outer joins

LEFT OUTER JOIN:
  • A left outer join or a left join returns results from the table mentioned on the left of the JOIN keyword irrespective of whether it finds matches or not.
  • If the ON clause matches 0 records from table on the right, it will still return a row in the result—but with NULL in each column.

RIGHT OUTER JOIN:
  • A right outer join or a right join returns results from the table mentioned on the right of the JOIN keyword irrespective of whether it finds matches or not.
  • If the ON clause matches 0 records from table on the left, it will still return a row in the result—but with NULL in each column.

FULL OUTER JOIN:
  • A full outer join will combine results of both left and right outer join. Hence the records from both tables will be displayed with a NULL for missing matches from either of the tables.

CROSS JOIN:
  • A cross join also known as cartesian product between two tables joins each row from one table with each row of the other table.
  • A cross join does not include 'on' clause.
Two tables are created and values are inserted using following SQL statements.

CREATE TABLE A (ID numeric)

INSERT INTO A VALUES(1)
INSERT INTO A VALUES(2)
INSERT INTO A VALUES(3)

CREATE TABLE B (ID numeric)

INSERT INTO B VALUES(4)
INSERT INTO B VALUES(5)
INSERT INTO B VALUES(6)

Using the above tables, try to answer the following questions.

Questions:

1. What will be output of following query?


SELECT A.* from A inner join B on A.ID=B.ID

(A) 1, 2, 3, NULL, NULL, NULL
(B) 1, 2, 3
(C) NULL, NULL, NULL
(D) 0 Rows


2. What will be output of following query?

SELECT A.* from A left outer join B on A.ID=B.ID
(A) 1, 2, 3, NULL, NULL, NULL
(B) 1, 2, 3
(C) NULL, NULL, NULL
(D) 4, 5, 6


3. What will be output of following query?


SELECT A.* from A right outer join B on A.ID=B.ID

(A) 1, 2, 3, NULL, NULL, NULL
(B) 1, 2, 3
(C) NULL, NULL, NULL
(D) 4, 5, 6


4. What will be output of following query?


SELECT A.* from A full outer join B on A.ID=B.ID

(A) 1, 2, 3, NULL, NULL, NULL
(B) 1, 2, 3
(C) NULL, NULL, NULL
(D) 4, 5, 6


5. What will be output of following query?


SELECT A.* from A cross join B

(A) 1, 2, 3, NULL, NULL, NULL
(B) 1, 2, 3
(C) NULL, NULL, NULL
(D) 1, 2, 3, 1, 2, 3, 1, 2, 3

Show Answers:

Tuesday, December 7, 2010

Questions on Choosing an Authentication Mode

When you install SQL Server 2005, the database engine can be set to any of two types of Authentication modes, Windows Authentication mode and Mixed mode.

Windows Authentication Mode:

  • It is default authentication mode.
  • It provides high level of security.
  • It mandates that only users who are previously authenticated to windows OS can connect to SQL Server.

Mixed Authentication Mode:

  • Client applications submits user name and password to connect to SQL Server.
  • When using 'Mixed mode' you can use either 'Windows authentication' or 'SQL Server authentication' to connect to SQL Server.
  • Non-windows users (unix, macintosh) use this mode.


If Windows Authentication mode is selected during installation, the sa login is disabled. If you later change authentication mode to Mixed mode, the sa login remains disabled. To enable the sa login:
Execute the following statements to enable the sa password and assign a password.

ALTER LOGIN sa ENABLE;
GO
ALTER LOGIN sa WITH PASSWORD = '';
GO


Adhering to Password Policies:
To ensure SQL login security, SQL Server 2005 lets you to use AD's password policy and password complexity. You can do the following.

  • You can force password policies.
  • You can use password complexity.
  • You can force password expiration.
  • You can force users to change their password at next logon.

Passwords entered on the Authentication page must meet strong password policy requirements. Strong passwords are not readily guessed by any one, and are not easily hacked by using a computer program.

Follow these guidelines when you set passwords:

1. Strong passwords cannot use prohibited conditions or terms, including:

  • A blank or NULL condition
  • "Password"
  • "Admin"
  • "Administrator"
  • "sa"
  • "sysadmin"

2. A strong password cannot use the following terms associated with the installation computer:

  • The name of the user currently logged onto the computer.
  • The computer name.

3. A strong password must be at least six characters in length and satisfy at least three of the following four criteria:

  • It must contain uppercase letters.
  • It must contain lowercase letters.
  • It must contain numbers.
  • It must contain non-alphanumeric characters – e.g., #, %, or ^.



Questions:

1. You are tasked to implement a password policy for users connecting to your database. You must also provide access to non-windows clients. Which authentication modes you will use?
(a) Windows Authentication mode.
(b) Mixed Authentication mode.

2. Which of the following are true when talking about SQL Server 2005 password policies?
(a) You can force password policies.
(b) You can use password complexity.
(c) You can force password expiration.
(d) You can force users to change their password at next logon.

Show Answers: