SQL Server 2005 Debugging Requirements

There have been some questions about the sysadmin requirement of SQL Server 2005 Debugging, and I’d like to explain it in some details.  When you debug T-SQL or CLR code in SQL Server 2005, there are two users involved: user running the debugger and user making the connection that is being debugged.  User running the…

11

Exception handling in SQLCLR

Naveen covered the TSQL exception handling in his posts on sqlprogrammability blog site. How does the TSQL exception handling mechanism interacts with SQLCLR exception handling mechanism? We will cover this topic in this post.   When SQL server execute a user function/procedure/trigger implemented in CLR (i.e., managed code), we will install a managed exception handler around the…

2

Overview of T-SQL and CLR debugging in SQL Server 2005

SQL Server 2005 ships with a new debugging engine that supports debugging of any T-SQL and CLR code running in the server, including batches, stored procedures, user defined functions/aggregates/triggers, etc.  You can use Visual Studio 2005 to debug against SQL Server 2005 or SQL Server 2000, but you can not use Visual Studio 2003 or…

15

Strong named assemblies and AllowPartiallyTrustedCallers

  Very often, you may wish to factor out your code into separate assemblies in your application. For example, you separate your type in one assembly because it gets used by multiple areas in your application. And you save your proc that uses that type in another assembly. So Let’s say you have two CLR…

1

Creating a CLR user define aggregate (part 1). Simple CLR aggregate

SQL Server 2005 allows creating of User Defined Aggregate in any of the .NET  languages such as C# or VB. For simple cases like SUM or MAX you probably want  to use built-in aggregates, however there are cases  where build-ins are insufficient. In such cases people used to put the business logic on a client…

7

Impersonation in SQL CLR

When the user code will try to access a resource outside of the SQL server it will run in the security context under which SQL Server is running. But this is not the ideal situation since it could become a security issue when the logged user that calls the code has less privileges than account…

5

Assembly redirection and CLR Integration

Assembly redirection is not supported in SQL CLR. Assembly redirection can be done using publisher, application configuration and machine configuration files.  SQL Server 2005 uses application configuration to redirect assembly call after Alter Assembly. So let’s suppose there is an assembly A calling assembly B and the user will run Alter Assembly command for B (modifying…

5

Satellite assemblies in SQL Server 2005

This is a sample on how to register satellite assemblies in SQL Server 2005.   Based on the CultureInfo on the executing thread, CLR will try to load the respective resource assembly. It should not be a difference between satellite assemblies inside and outside of the SQL CLR other than location: if for a normal…

1

Best Week Ever

SQL Server provides the ability to find the week of the year in which a given date lies.  For example: declare @d datetimeset @d = ’13 november 2005’select datepart(ww, @d) The result of this is 47. Now, the problem with this is that the correct result according to ISO 8601 is 45, not 47.  Why? …

11