Welcome to MSDN Blogs Sign in | Join | Help

 

I promised few days ago that I'll be blogging frequently on this blog, writing several articles about SQL Server Management Tools and Libraries.

I'll start with SMO (SMO stands for SQL Server Management Objects), which is simply a group of classes to control SQL Server and do whatever you could make with traditional T-SQL.

During the upcoming articles, I'll go through all SMO classes and in every article I'll try to cover one class with examples on it.

 

For now, let's begin with the main class which is nearly used by all SMO classes: Server class

This class simply encapsulate the SQL Server instance, and includes many utility APIs for dealing with SQL Server instance, like getting the version, getting all attached databases, tables in each database, etc.

In this example, I'll be using SMO version 9.0.2047.0 (SQL Server 2005 + SP1), so the requirements for running this sample, are:

  1. .Net framework version 2.0
  2. Microsoft SQL Server 2005 with Client Tools  + Microsoft SQL Server 2005 Service Pack 1

 

In this article, we'll do a small sample to enumerate some type of objects of the SQL Server instance:

  1. Databases.
  2. Views.
  3. Tables.
  4. Columns.
  5. Indexes.
  6. Keys.
  7. Triggers.
  8. Functions.
  9. Stored Procedures.

This is the organization of this sample:

 

  1. Prompt the user to input the server name, and his username/password (in case of SQL Server Authentication), or use Windows Authentication instead.
  2. Enumerate all the databases on that server.
  3. Whenever the the click any object from from the list of the supported objects in this sample, the object children (only those from the types supported in the list), will be displayed under this object.

 

So I believe that this is a very simple sample, and as I always believe, samples speak better than words, so I'll just put the link for this sample, and if any one interested to ask any question, feel free to post a comment on this article and I'll answer it as soon as I could.

You can download the sample from:

http://www.mmeshref.com/smo_server_sample.zip

Thank you so much.

Hello all,

I'll begin a series of articles on SQL Server Manageability, which includes SMO (SQL Server Management Objects), Database Mail, SQL Server Agent, SSMS (SQL Server Management Studio) and more.

 

Most of articles will be on SMO because it's really huge, and knowing this fact, I'll insert an article or two on other subject rather than SMO every three of four SMO articles.

Now let's define the main components of SQL Server Manageability:

 

1- SMO:

SMO stands for SQL Server Management Object, simply it's a library which includes dozens of classes which could do anything the user could make using normal T-SQL or using SSMS (which is built on the top of SMO), in other words, you could nearly manage any SQL Server feature through SMO (there's another library named RMO which do the same like SMO but for SQL Server Replication), you can make databases, tables, indexes, send database emails, virtually make anything through very easy set of C# classes, SMO will be the main subject of my articles here, you can access SMO through its official library: Microsoft.SQLServer.Management.SMO.dll

 

2- Database Mail:

Database Mail is an enterprise solution for sending e-mail messages from the Microsoft SQL Server 2005 Database Engine. Using Database Mail, your database applications can send e-mail messages to users. The messages can contain query results, and can also include files from any resource on your network. Database Mail is designed for reliability, scalability, security, and supportability.

 

3- SQL Server Agent:

SQL Server Agent is a Microsoft Windows service that executes scheduled administrative tasks, which are called jobs. SQL Server Agent uses SQL Server to store job information. Jobs contain one or more job steps. Each step contains its own task, for example, backing up a database. SQL Server Agent can run a job on a schedule, in response to a specific event, or on demand. For example, if you want to back up all the company servers every weekday after hours, you can automate this task. Schedule the backup to run after 22:00 Monday through Friday; if the backup encounters a problem, SQL Server Agent can record the event and notify you.

 

4- SSMS (SQL Server Management Studio):

Microsoft SQL Server Management Studio, new in Microsoft SQL Server 2005, is an integrated environment for accessing, configuring, managing, administering, and developing all components of SQL Server. SQL Server Management Studio combines a broad group of graphical tools with a number of rich script editors to provide access to SQL Server to developers and administrators of all skill levels.

SQL Server Management Studio combines the features of Enterprise Manager, Query Analyzer, and Analysis Manager, included in previous releases of SQL Server, into a single environment. In addition, SQL Server Management Studio works with all components of SQL Server such as Reporting Services, Integration Services, SQL Server Mobile, and Notification Services. Developers get a familiar experience, and database administrators get a single comprehensive utility that combines easy-to-use graphical tools with rich scripting capabilities.

 

5- SQL CMD Utility:

The sqlcmd utility allows you to enter Transact-SQL statements, system procedures, and script files at the command prompt. This utility uses OLE DB to execute Transact-SQL batches.

 

That's all for a quick intro, next time I'll begin in SMO, so stay tight ;)

Hello all,

 

It has been a very long time since I've posted my first entry in this blog, but finally I am back, and I'll begin writing many articles for SQL Server Managibility (things like SMO, Database Mail, Agent, etc) starting from this week.

 

Please stay tight and visit the blog frequently

Thanks!

Hello everybody,

 

This is my msdn technical blog, here you'll find my technical posts (as soon as I understand everything here and have the ability to write technical articles :D).

If you're searching for my personal information, you won't find them here in this blog, you'll find them in my other blog which is: http://mmeshref.blogspot.com

Although, you would find the links for these two blogs in addition to my photo album in my main site which is: http://www.mmeshref.com

 

So, welcome in my technical blog and which you to enjoy your time here :)

 
Page view tracker