Wednesday, July 14, 2010

SQL Server Express 2008 now 10GB!

In case you are not aware, you now get 10GB with the free edition of SQL Server 2008 Express edition!.
Greate news, check out at their official website SQL Server Express 2008

C# extension method similar to Sql's IN operator

Consider the code snippet below
if(a == x || a == y || a == z)

We can re-write this expression as:
  • Using array's contains
 if( new [] {x,y,z}.Contains(a))
  • Using a similar syntax for the SQL's IN operator by using extension
public bool IsIn(this T obj, params T[] collection) {
   return collection.Contains(obj);
And invoke as
if(a.IsIn(b, c, d)) { ... }

Read more at Stackoverflow

Wednesday, July 07, 2010

Find the Port a Connection is Using in Sql Server

SELECT c.session_id, c.local_tcp_port, s.login_name, s.host_name, s.program_name
FROM sys.dm_exec_connections AS c INNER JOIN
            sys.dm_exec_sessions AS s on c.session_id = s.session_id
WHERE c.local_tcp_port <> 1433

I found this very useful when monitoring external access to your Sql Server instance.

The original post was here at SqlServerCentral