.NET Stored Procedures vs T-SQL in SQL Server 2005

One of the extremely new features of SQL Server 2005 is the CLR integration into its core engine: now you can write stored procedures with any .NET language and use them directly into your SQL Server engine.

Writing a SQL Server stored procedure with Visual Studio 2005 is quite simple. The steps are summarized as follow:

1) Open Visual Studio 2005, select New Project, select Database an the right hand pane of the new project dialog choose SQL Server Project.

2) Now you've to choose the database where you want to work (a SQL Server 2005 database) and after this choice you're project will be created.

3) Right click the project in the Solution Explorer, choose Add and then Stored Procedure from the context menu.

4) Now you're ready to begin writing your CLR Stored Procedure.

The newly created stored procedure will be deployed as a .NET dll and to deploy it you can right click your project in Visual Studio Solution Explorer and choose Deploy.

Ok... but the core of this post is another...  what are the performances of T-SQL against SQL CLR integration?

This is a question that I want to launch for all who has started to play with these new features. Before the SQL Server 2005 launch I've always thinked that SQL CLR integration was a lot slowest that T-SQL procedures, but after the tests that I've done on my environments I can't confirm this. Performance of SQL CLR integration are a big surprise, totally comparable to the T-SQL language!

This has a terrible impact on production environments: you can write complex SQL routines and user defined functions directly with your favourite .NET language, deploy it into the SQL CLR engine and start work without loss of performances! (and writing a complex SQL function with a .NET language is always more simple than writing it with T-SQL I think).

Obviously, SQL CLR usage must not be abused and I think that using T-SQL for the standard CRUD operations is always the best choice (T-SQL is fast!), but for complex operations and calculations, don't worry about SQL CLR perfomances: your new SQL functions can be fast and written without the complexity of the T-SQL language. The myth that SQL CLR procedures are slow is a fake!!

Print | posted on Thursday, February 09, 2006 3:27 PM

Comments on this post

# Taking the right decision...

Requesting Gravatar...
Left by STEFANO DEMILIANI WeBlog on Feb 10, 2006 2:49 AM

# SQL Server 2005 and CLR Integration: what about security?

Requesting Gravatar...
Left by STEFANO DEMILIANI WeBlog on Mar 01, 2006 2:15 PM

# Microsoft » Blog Archives » The Common Language Runtime is at the heart

Requesting Gravatar...
Microsoft » Blog Archives » The Common Language Runtime is at the heart
Left by Pingback/TrackBack on Oct 28, 2006 10:35 PM

# Microsoft » Blog Archives » <I>The T-SQL language in the upcoming version of

Requesting Gravatar...
Microsoft » Blog Archives » <I>The T-SQL language in the upcoming version of
Left by Pingback/TrackBack on Nov 04, 2006 5:24 AM

# Microsoft » Blog Archives » T-SQL Language Enhancements. Transaction Abort Handling. Where Are

Requesting Gravatar...
Microsoft » Blog Archives » T-SQL Language Enhancements. Transaction Abort Handling. Where Are
Left by Pingback/TrackBack on Nov 17, 2006 10:50 AM

# Microsoft » Blog Archives » Language : C++ examples (example source code) Organized by topic

Requesting Gravatar...
Microsoft » Blog Archives » Language : C++ examples (example source code) Organized by topic
Left by Pingback/TrackBack on Jan 19, 2007 10:26 PM

# re: .NET Stored Procedures vs T-SQL in SQL Server 2005

Requesting Gravatar...
Can you give us some CLR stored procedure you used in your environment
Left by dip on Feb 05, 2009 9:54 PM

# replica watches

Requesting Gravatar...
:) thank u for ur comment~
Left by watch replicas on Apr 28, 2010 12:18 PM

# re: .NET Stored Procedures vs T-SQL in SQL Server 2005

Requesting Gravatar...
ne of the extremely new features of SQL Server 2005 is the CLR integration into its core engine: now you can write stored procedures with any .NET language and use them directly into your SQL Server engine.

Writing a SQL Server stored procedure wi
APPLE laptop battery
Left by wholesale laptop adapter on May 23, 2010 2:32 PM

Your comment:

 (will show your gravatar)
 
Please add 7 and 2 and type the answer here: