Welcome to the Application Development Virtual Chapter

Our Mission

Our mission is to serve as a hub of free training and information for application developers working with Microsoft SQL Server, sharing best practices, tips, and techniques and helping fellow community members avoid trials and tribulations.

A Fresh Start in 2013

After a transition year in 2012, we're looking forward to 2013 as a fresh start for the Application Development Virtual Chapter. We hope you rejoin us in this exciting new chapter for our group, and contact us at appdev_DL@sqlpass.org if you'd like to volunteer with the VC or speak at one of our meetings.

Contact Us

Please contact us at appdev_DL@sqlpass.org or via Twitter (@PASSAppDev) or our Linkedin Group to find out more about the PASS AppDev Virtual Chapter.

 Upcoming Meetings

March 2013 Presentation

 

When:

Friday, March. 8th 12:00PM MT

 

Asynchronous Programming with Service Broker

Service Broker, introduced in Microsoft SQL Server 2005 provides a robust asynchronous messaging infrastructure that can leverage the asynchronous programming model and boost your application’s throughput. Service Broker offers the flexibility to separate and queue the trivial tasks from the critical ones in a workflow, while guaranteeing successful completion of the queued tasks. This, coupled with its opportunities for increased parallelism, can translate to big improvements in both performance and scalability. This session will not only introduce you to service broker architecture, terminology, features and usage scenarios, but will also walk you through the steps from set up to troubleshooting.

 

Sanil Mhatre Bio:

Sanil Mhatre is a SQL Server 2008 MCTS with a Master’s degree in Information Systems. As a Database Developer, he currently focuses on the SQL Server platform for a Healthcare company in St. Louis.Starting as a Java Developer, Sanil turned his interests toward databases while migrating an application from DB2 to Oracle. Sanil now enjoys switching hats between database development and administration across multiple database platforms. Sanil servers on the board of the St. Louis SQL Server User Group, organizes the St. Louis SQL Saturday, Volunteers with various PASS committee and speaks at local and regional technical conferences. He also contributes on MSDN Forums and blogs at http://sqlwithsanil.com/

 

How do I attend the meeting? LiveMeeting


 

 Resources

Featured Articles

Facts to Learn about Triggers and Transactions by Snehalatha K Thommandram
Invoking Triggers using OLEDB Destination in SSIS by Snehalatha K Thommandram
Dynamic SQL Resources
by Jeremiah Peschka
Time to Get Tested by Todd Robinson
Time to Get SMOoth by Todd Robinson

Previously Featured Articles

Facts to Learn about Triggers and Transactions (SQL 2005)

1) A trigger always works as if there is a pending transaction. This is
because a trigger is fired when the DML statement for which it is written
is executed, regardless of whether the statement is executing in the
implicit or explicit transaction mode.

2) In versions later than SQL 7.0 the @@TranCount global variable only gets
incremented if the count is 0 before you begin the transaction

Best Practices Based on the Facts Above.

a) In a trigger, always start an explicit transaction keeping in mind the
pending transaction that invoked the trigger won't cover the batch in the
trigger.

b) If you are too lazy (like me) to start a nested transaction and try to
use COMMIT OR ROLLBACK inside trigger, you will end up getting an error 3609
along with the message "the batch is terminated"
Source: Rollbacks and Commits in Stored Procedures and Triggers (BOL)

Invoking Triggers using OLEDB Destination in SSIS

A trigger is automatically fired, when a DML statement for which it is written is executed for e.g.: Insert, Update and Delete. That is not always the case if you use SSIS OLE-DB component task, I was new to BI development and I got excited to test the insert trigger defined on a particular table using SSIS.
 
So, I opened BI Studio and created a simple package to insert rows using Execute SQL Task, wrote a source query and an OLE-DB destination to insert rows in to the table, only to realize, the trigger won’t be fired unless you explicitly use the FIRE_TRIGGERS option using the Advanced Editor of the OLE-DB Destination.
 
Here is how you do it:
 
In the OLE-DB Destination Editor set the Data Access Mode to “Table or View – Fast Load” and hit OK.
 
Right Click the OLE-DB Destination Editor and Click “Show Advanced Editor”
 
Click on the Component properties tab and in the Fast Load Option type “FIRE_TRIGGERS” preceded by a comma. Set FastLoadMaxInsertCommit Size to 1. Otherwise the trigger (in this case, insert trigger) would be fired only once.
 
Note: FastLoadOption is only available when set the Data Access Mode to Table or View – Fast Load”  
 The above work around may not be performance-friendly but it helped me test whether a trigger that I am interested in is working properly or not.
 
Advanced Editor for OLE DB Destination
 

Dynamic SQL Resources

Finding good resources on working with dynamic SQL can be difficult. Many DBAs and developers ignore this powerful tool and choose to work with more cumbersome solutions.

Stored Procedures - Executing & Dynamic SQL - SQL Server Pedia has a short article about working with the EXEC statement and the sp_executesql system stored procedure. Understanding how both of these work is fundamental to working with dynamic SQL.

SQLQueryStress - SQLQueryStress is a tool developed by Adam Macahanic that you can use to stress test queries and determine the frequency of query plan recompilation, amongst other things.

Batch Compilation, Recompilation, and Plan Caching Issues in SQL Server 2005 - This whitepaper from Microsoft covers a number of the issues that can make dynamic SQL perform poorly: namely compile and recompile times as well as parameter sniffing. While this paper does not give any dynamic SQL specific solutions, it highlights the causes of these issues and provides tools and techniques to identify and solve these issues.

Automating T-SQL Testing - I'm shamelessly linking to myself here, but with good reason. I put together a T-SQL testing framework that makes heavy use of dynamic SQL. The benefit of this framework is that you can easily use it to run automated tests against dynamic SQL, especially when your dynamic SQL has optional parameters.

The Curse and Blessings of Dynamic SQL - This is probably the grandaddy of all resources on dynamic SQL. Erland Sommarskog works through many good coding practices for dynamic SQL and brings up security, formatting, and performance concerns and provides ways to address them.

 

Time to Get Tested by Todd Robinson

One of the frequent links I like to visit is the Microsoft Certifications blog by Gerry O’Brien. Here he lists information on the certifications for developer and SQL Server technologies. In his blog, you will find information on current beta exams which are in development. Best of all, these posts most often include a registration code good for the beta period which can be used to take the exam for FREE!

 I will stress though that if you do take them up on this wonderful offer that you

Show up – Nothing would make Gerry sadder then to offer these and have people not take them.

Be prepared – Look on the Microsoft Certification site for the objectives. These will give you an idea what will be on the exam.

Leave constructive comments – This is your chance to tell Microsoft how well they are doing! If a question might have an ambiguous answer, let them know, but also explain why you think so. If a question is hard to read or formatted weird, let them know how it could be better. The most important thing to remember is that your comments will be used to make a better exam experience for everyone.

GerryO’s blog can be found at http://blogs.msdn.com/gerryo/

Good luck on your next exam!

 

Time to Get SMOoth by Todd Robinson

 I just started a new position at a company where my main goal is to help them look over the performance, stability and disaster recovery of all their SQL Servers. During the first few days, you have to become acclimated to the systems, find out who supports what, and ultimately find out what are the servers that you’ll ultimately be responsible for.

They set me up with my workstation, granted me access to the database administrators group, and let me have at it. My first order of business was just to see what’s out there on the network. Previously, if you just wanted a list of all the servers that could be discovered on the network, you would use Osql with the –l parameter. It would return a list of all the servers it was able to browse on the network.

I ran this and saw many more rows than the 40 or so I was expecting. Obviously, there were some servers out there that hadn’t been documented. I wanted to gather a bit of details about these servers, specifically the version, just so I could see what I was facing. So what was the best way to do this?

I decided that I would use SQL Management Objects (SMO) to gather the same list of servers and hopefully get a bit more information out of them. Once I had my list I could delve further.

I brought up Visual Studio and started a new C# console application. In order to use SMO in your project, you need to add the references to the appropriate assemblies. Since I just want to list the servers out on the network as well as their version, at this time I will only need the Microsoft.SqlServer.Smo namespace.

Now I can add it to the list of directives at the top of the app so I don’t have to type everything out.

using Microsoft.SqlServer.Management.Smo;

Since I’m going to use a DataTable to store these values, I also want to add the directive

using System.Data;

Now I’m ready to start to get the info I want.

Inside of the Main function, the first thing I want to do is get a list of all the servers that are broadcasting on the network. To do this, I can use the EnumAvailableSqlServers method. You can specify the name of the server or instance you want to discover by providing the string as a parameter, but in this case, we want to see them all, so we don’t pass anything. This method in the SmoApplication class returns a DataTable with the enumerated list of SQL Servers. This table contains the columns Name, Server, Instance, Version, and isLocal and isClustered

DataTable dt = SmoApplication.EnumAvailableSqlServers();

Now that we’ve populated a table with the servers, we can iterate through the collection

if (dt.Rows.Count > 0)
{
  foreach (DataRow dr in dt.Rows)
    {
    Server svr = new Server((string)dr["Name"]);
    Console.Write(svr.Name);
    //Comment out the following line for a list just like OSql -l
    Console.Write(" "+ svr.Information.VersionString);
    Console.WriteLine();
  }
}

Now when we run this application, we get a list of all the servers that are broadcasting on the network along with its version. In the next article, we’ll take this code and build on it to create a list of servers that we can access, as well as a list of “rogue” servers. 

 Announcements

The PASS Application Development Virtual Chapter
website is getting updated!

Here at AppDev_VC, we like to think we're forward minded, outgoing kinds of people. So we got together on the phone and talked about ways we could make the visits to your favorite PASS site a more enjoyable and rewarding experience. Over the next days and weeks, you'll start to see changes happening here, with additions such as exclusive SQL Server Development articles, links to some of the best learning and support sites out there, and of course, the best speakers on the subject of SQL Server Development out there. We've even got some BIG surprises in store for you, so come back often and see how we grow!

Of course, if you have suggestions for anything you'd like to see here at AppDev_VC, drop us a note at appdev_DL@sqlpass.org - we're open to ideas, and would love to hear from you!

 

 Program Partners

PASSChapterLogo100.jpg 

 

sql_micro_sm.gif 

sql_ca_sm.gif