Wednesday, December 15, 2010

10 things you should know about SQL Server 2005 Management Studio


Takeaway: SQL Server 2005 Management Studio is a phenomenal advance over the tools provided with SQL Server 2000. Check out the improvements in SQL Server Management Studio, which makes it easier to locate errors in your code and allows you to keep tabs on your reports.

By Arthur Fuller and Stephen Giles

Microsoft SQL Server 2005 contains a number of major new features, but the feature that we like the most is the SQL Server Management Studio. This tool is leaps and bounds beyond what was available in earlier versions of SQL Server. Here is a list of the 10 things that we find most useful about SQL Server Management Studio.

1. Combines the best features of many tools
In earlier versions of SQL Server, you had two main tools: a graphical administration tool (Enterprise Manager) and a Transact SQL Editor (Query Analyzer). The problem with this split is that we do development and administration on SQL Server (sometimes at the same time) and often have to flip back and forth between the two. In SQL Server Management Studio, the Enterprise Manager and Query Analyzer are combined into one common interface, allowing you to manage your servers graphically and to write Transact SQL.

SQL Server Management Studio also allows you to access an Object Browser for all registered servers, which combines the features of the Object Browser from Query Analyzer with the Server tree view from Enterprise Manager. In addition, it provides a workspace similar to Query Analyzer, with the expected tools like the Language Parser and the Graphical Show plan. Now you can write queries and scripts and manipulate objects with Wizards and Property sheets in the same tool at the same time.

SQL Server Management Studio's interface has a separate Registered Servers view that allows you to work with multiple servers at the same time. You can do this in Enterprise Manager; however, SQL Server Management Studio allows you to register server instances as well as all Analysis Services, Reporting Services, SQL Server Integration Services, and Mobile SQL instances. Thus, you can obtain an enterprise view or concentrate on the particular instances and objects of interest.

2. Work with projects and solutions
If you have worked with Visual Studio, then you are familiar with the concept of projects and solutions. In a nutshell, projects allow you to group files together and access them as a unit. A solution is a series of projects, enabling you to drill down to projects just as OLAP users can drill down to the data dimension of interest.

A project can contain .sql, .mdx, .xmla, and .dmx scripts. You can also add other files (such as XML or CSV files) to a project. Therefore, the project itself is a drill-down object.

To create a new project, follow these steps:
1. Click File | New | Project.
2. Choose the type of project you want to create (SQL Server Scripts, Analysis Services Scripts, or SQL Mobile Scripts).
3. Give your project and solution a name.
4. Select the path where you want to store the files.
5. Click OK.

Now you can define various data sources (if your project touches more than one database) and add files effortlessly (simply right-click the Scripts folder in the Solution Explorer and select the items to add). You can also import scripts into a project if you have done some work already.

(If you don't see the Solution Explorer in your SQL Server Management Studio, select View | Solution Explorer or hit [Ctrl][Alt]L.)

3. The tool is a data analyst's best friend
Thanks to the integration of the OLAP tools, SQL Server Management Studio is a great tool for working with your cubes. The object browser allows you to access Analysis Services objects to graphically manage your cubes. It also lets you write and execute MDX and DMX and XMLA statements from within the editor window, allowing you to run both OLTP and OLAP queries from the same tool and even from within the same project.

4. You can display line numbers


How many times within Query Analyzer have you had to walk down the lines to count up to the line flagged with an error? With SQL Server Management Studio, you can display line numbers in the code editor, which is extremely helpful when you're parsing code to locate the problem line and inevitable typos.

This feature is not turned on by default. Here's how to enable line numbers:
1. Select Tool | Options.
2. Expand Text Editor in the Options Tree and select All Languages.
3. In the property pane on the right, select the Line Numbers check box under the Display heading.

There is one "feature" with line numbering. If you have batch statements in your script (Begin...End or Go statements), the results page will recalculate line numbering within the block (i.e., it will start counting from line 1).

5. It's easier to find errors
SQL Server Management Studio has retained one of our favorite features of Query Analysis: linking to errors in the body of your script from the error message in the Message pane. Note that the line number referenced in the error message may not correspond to the line numbering if a script contains multiple batches. You can, however, find the line causing the error simply by double-clicking the error (the red text) in the Message pane. This action will highlight the offending line in the body of the script. (You may want to use the pre-parse function with this feature to clean up all syntax errors before running a script.)

6. Get started faster with an expanded Template Explorer
Transact SQL is the language of SQL Server, and (as with other versions of SQL Server) you can perform all tasks from queries to object creation through Transact SQL. We like scripting objects primarily because it allows us to have absolute control over what we create, and we can save scripts to document objects and move them easily from a test to a production environment.

However, new features mean new syntax, and thus much more to remember. To make life easier, the SQL Server Management Studio includes an updated Template Explorer (View | Template Explorer or [Ctrl][Alt]T) that lays out the structure of more than 100 objects and tasks in Transact SQL, including administrative tasks like backing up and restoring databases.

Due to the integration of formerly disparate tools, the Template Explorer now includes templates for both Analysis Services and SQL Mobile commands. This means that you can drive DMX, MDX, and XMLA expressions through script templates the same way you could create objects in earlier versions of Query Analyzer.

7. It (sort of) plays well with previous versions
SQL Server Management Studio can run through the SQL Server Distributed Management Objects (DMO) as well as the SQL Management Objects (SMO), which are the preferred management objects for SQL Server 2005. This means that you can administer SQL Server 2000 and MSDE databases using the SQL Server Management Studio. This allows you to keep your databases in previous versions while administering them from SQL Server 2005. One caveat is that SQL Server Management Studio's version of DMO will not allow you to administer SQL Server 7.0 servers. You should consider this yet another good reason to upgrade.

8. Name that registered server
When registering our databases (both in Enterprise Manager and SQL Server Management Studio), we like to use an IP address rather than a server name; this approach facilitates remote connections across a VPN, and name resolution can sometimes be a problem. In Enterprise Manager, we had to remember the IP address for each particular server for which we work. For this purpose, we kept a text file listing all the connection parameters.

In SQL Server Management Studio, you can register by IP address but still give the computer a more recognizable name and even add a description of the server. The name and description will show up on the Registered Servers pane (View | Registered Servers or press [Ctrl][Alt]G), so you always know which server you are working on.

9. Manage your SQL Server Integration Services pages
Microsoft intended for SQL Server Management Studio to enable you to manage all services in one consistent UI, which is the case with the SQL Server Integration Services (SSIS). SSIS is the replacement for DTS in earlier versions of SQL Server and is also utilized by the new Maintenance Plan Wizard.

In SQL Server Management Studio, you can view all packages on a server and see which packages are currently running. You can also Import and Export packages using this tool (which is something that was not easy to do in earlier versions of SQL Server), and run packages from within the SQL Server Management Studio. To access SSIS through SQL Server Management Studio, follow these steps:
1. Register a server through the Integration Services tab in Registered Servers.
2. Right-click the Server and select Connect | Object Explorer.
3. Manage your packages through the tree that appears in the Object Explorer.

10. Keep tabs on your reports
As with Analysis Services and SSIS, you can use SQL Server Management Studio to manage your Reporting Services. In the SQL Server 2000 version of Reporting Services, all administration was carried out through a Web-based administrator that was installed as part of Reporting Services. If you managed several report servers, you had to manage each one through separate admin sites.

In SQL Server Management Studio, you can register all of your Reporting Services and administer them through the Object Explorer. You can also perform all tasks that were available on the Reporting Services admin site through the Object Explorer.

To access Reporting Services through SQL Server Management Studio, follow these steps:
1. Register a server through the Reporting Services tab in Registered Servers.
2. Right-click the Server and select Connect | Object Explorer.
3. Manage your packages through the tree that appears in the Object Explorer.

Conclusion
SQL Server 2005 Management Studio is a phenomenal advance over the tools provided with SQL Server 2000. We have gone so far as to remove the SQL Server 2000 tools, and we now do everything in SQL Server 2005. This version of SQL Server provides great leaps forward plus backward compatibility, which in our book is a winning combination.

Thursday, December 9, 2010

12 common mistakes done by programmers

Most often, software developers seem locked into certain failure modes that can't be avoided and such is the frequency with which they fall prey to a particular poor programming practice.Peter Wayner of Computerworld writes about twelve most common programming mistakes, each of which is accompanied by its opposing pair. Below are the twelve programming pitfalls developers should stay away from.

Playing it fast and loose
Failing to prop up the basics is the easiest way to make errors in coding. There are a lot of small places where a developer may make a mistake which causes software to fail. And the worst part about sloppy programming is that advances in language design aimed to fix these problems don't do their job. There have been improvements in syntax in programming languages. For instance, the latest version of Java tries to make null-pointer checking easier by offering shorthand syntax for the endless pointer testing. But such syntax improvements can only prevent code from crashing. They don't eliminate the root of the problem: the proliferation of null values due to fast and loose programming.

Overcommitting to details
On the flip side, overly buttoned-up software can slow to a crawl. Relentless devotion to detail can even lock up software if the obsessive checking requires communicating with a distant website over the network. Here, the challenge is to design the layers of code to check the data when it first appears, which is much easier said than done.

Not simplifying control
Not simplifying control over tasks in their code may invite disaster for developers. The software assumes that if someone creates an object of type Name with two fields first and last, then it should immediately create a database table called Name with two columns, first and last. The names are specified in only one place, avoiding any problems that might come if someone fails to keep all of the layers of configuration in sync.

Delegating too much to frameworks
Sometimes the magic tools lead only to confusion. By abstracting functionality and assuming what we want, frameworks can all too often leave developers at a loss for what's gone wrong in their code. The rules are, while quite reasonable, not entirely trivial. As the app grows, it depends on more and more of these almost-trivial bits of external knowledge.

Trusting the client
Many of the worst security bugs appear when developers assume the client device will do the right thing. For example, code written to run in a browser can be rewritten by the browser to execute any arbitrary action. If the developer doesn't double-check all of the data coming back, anything can go wrong.

Not trusting the client enough
Sometimes too much security can lead paradoxically to gaping holes. Because of this, many Web developers are looking to reduce security as much as possible, not only to make it easy for people to engage with their products but also to save them the trouble of defending more than the minimum amount of data necessary to set up an account.

Relying too heavily on magic boxes
Many programmers assume they can link in the encryption library, push a button, and have iron-clad security. But many of these magic algorithms have subtle weaknesses, and avoiding these weaknesses requires learning more than what's in the Quick Start section of the manual.

Reinventing the wheel
Then again, writing your own libraries just because you think you know a better way to code can come back to haunt you. But grow-your-own cryptography is a welcome sight to attackers. Many libraries don't need to be perfect, so grabbing a magic box is more likely to be better than the code you write yourself.

Opening up too much to the user
Placing the onus on users to customize functionality they do not fully understand can invite disaster in the form of inadvertent security holes and privacy violations. When making purchasing decisions, most users can't handle the breadth of features offered by any given piece of software.

Overdetermining the user experience

Some developers decide to avoid the trouble of too many features by offering exactly one solution. But if users don't like the idea, they will look for ways to work around these limitations, and it will lead to an outcome that could translate into security vulnerabilities.

Closing the source
The decision to not distribute code works against the integrity of that code and it can discourage innovation and fixing bugs. Just opening up the code forces you to make the info more accessible, understandable, and thus better.

Assuming openness is a cure-all
While openness can make it possible for others to pitch in and, thus, improve your code, the mere fact that it's open won't do much unless there's another incentive for outside contributors to put in the work. Opening up a project can also add new overhead for communications and documentation. Moreover, a good open source project comes with extensive documentation of the API and road maps for future development.

Thursday, December 2, 2010

10 mistakes every programmer makes

ITWORLD
If you have any question then you put your question as comments.

Put your suggestions as comments