From inspiration to realization
22Jun/091

Number of open connections SQL server

Hi all,

Normally, when do you your coding on a website or a system you're probably using connection to an SQL server database.

When you are the coder or you are a consultant coming to a company to check the code or the server or anything else for that matter you sometimes need to check the number of connections that are open right now.

This can be done to check the quality of the code regarding connections, of the code does not close the connections, eventually the server will close the pool and the website will no longer work.

I have seen people solving that by upping the number of allowed open connections, that of curse is not the solution (not the best solution).

OK, so if you are like me and you are running 1-9 servers that are dedicated to you, each running dozens or hundreds of db’s, this is an absolutely great method to catch a glimpse on what’s going on with your connections.

run this code on your server and see what happens:

   1: SELECT DB_NAME(dbid) as 'DbNAme', COUNT(dbid) as 'Connections' from master.dbo.sysprocesses with (nolock)

   2: WHERE dbid > 0

   3: GROUP BY dbid

this code will display a list of all the databases on your server with the open connections on each of them.

For security reasons I can’t show the entire result set, but here’s a sneak peak:

6-22-2009 6-51-36 PM

** This was checked on SQL server 2005/2008 both express and full versions.

good luck

  • Share/Bookmark
16Jun/092

Share your local drives over RDP – Windows 7

Hi All,

You probably work quite a bit with RDP connections to multiple servers around the globe.
I’m currently running 6 servers in Israel 4 in the US and some more around the world.

Uploading materials or downloading is sometimes quite a mission to handle if you don’t know this crazy little method.

You can share your local drives so that it will be visible to remote connections you manage, those drives are only mapped when you are connected and not someone else, so they are secure and easy to use.

You probably are doing what I did when I discovered this method, grabbing and pulling hard on your hair.

STOP!!!

Here is how you do it.

I’m using windows 7 RC2 but its the same in Vista, I can’t remember XP (OLD!) but I think you can do it in XP as well, it doesn’t seem like Microsoft did changes in this app.

First, let’s open RDP connection:

Start—>Run—>mstsc and click ENTER

This dialog popped up right?

6-16-2009 11-44-21 PM

Type in your computer (remote) name or IP address and click the options arrow (bottom left)

Once you do that a dialog opens up.
Click “Local Resources”… as shown in this image

6-16-2009 11-45-59 PM

Then click the '”More” button (bottom left), another dialog will pop open, and you will be able to check/uncheck the drives you want to share with the remote computer at the time of the connection.

Let’s hit “Connect” and open up “My Computer” on the remote server

This is how my it looks now

6-16-2009 11-49-44 PM

You can now download, Upload, copy, Paste and practically do whatever you want, it is like you are working on your local files.

Keep in mind: if you leave a folder (local) open on the server and you don’t log off this folder is now “read only” you won’t be able to delete the folder from your computer untill you log off the remote connection.

Good luck

I would love to hear and read your comments

  • Share/Bookmark