How can I get an accurate count of computers (workstations) logged in to my SQL Server database?

We license our software by number of workstations.
I have a query that I have used for years to get an accurate count of the workstations logged in to my SQL Server database. For simplicity, all users use the same login name/password. This is built in to the script that attaches to the DB. They
have access only to that DB with the exception of
USE [Master] GRANT VIEW SERVER STATE to MyUser
The query that has been working is below:
Basically this relies on the mac address (Master.dbo.sysprocesses.net_addre
SELECT COUNT(Users) AS UserCount FROM (SELECT COUNT(Master.dbo.sysprocesses.hostname) AS Users FROM Master.dbo.sysprocesses LEFT OUTER JOIN Master.dbo.sysdatabases ON Master.dbo.sysdatabases.dbid = Master.dbo.sysprocesses.dbid WHERE (Master.dbo.sysdatabases.name = 'MyDatabase') GROUP BY Master.dbo.sysprocesses.net_address) AS UserCount_1
ss), since both Workstation names and ip addresses can be duplicated.
Recently this has stopped working at a number of customers. Suddenly individual workstations are showing multiple net addresses for the same workstation causing a substantial overcount of users. This may be related to SQL Server 2012 - not sure.
What I need is a very reliable way to get a count of workstations logged in to my database.
If anyone can tell me why I am suddenly getting multiple net_addresses for each workstation and how to prevent that that would be one possible solution.
Otherwise if anyone can give me a rock solid way to get a workstation count other than the above that would be great. Our largest customer is 50 users by the way.
Thanks in advance for any help.
Kim

I think your count is getting skewed because of duplicate rows in sysprocesses because of parallelism. Add DISTINCT to your query:
SELECT COUNT(Users) AS UserCount
FROM
( SELECT COUNT(DISTINCT Master.dbo.sysprocesses.hostname) AS Users
FROM Master.dbo.sysprocesses LEFT OUTER JOIN Master.dbo.sysdatabases
ON Master.dbo.sysdatabases.dbid = Master.dbo.sysprocesses.dbid
WHERE (Master.dbo.sysdatabases.name = 'MyDatabase'
GROUP BY Master.dbo.sysprocesses.net_address) AS UserCount_1
Satish Kartan www.sqlfood.com

Similar Messages

  • How can I get the ip addres of computers that log into my Applet?

    How can I get the ip addres of computers that log into my Applet?
    Thanks
    REuven

    Try using method getAddress of class InetAddress.

  • How can I get the shutter count for my Canon 7D Mark II using Windows XP?

    How can I get the shutter count for my Canon 7D Mark II using Windows XP? I've been looking lots of places and doing some file uploads, but I can't seem to find anything. I'm wary of downloading software I know nothing about. Any help is greatly appreciated.
    Solved!
    Go to Solution.

    Nevermind, just, sort of answered my own question. Doesn't work on XP, but using a Win 7 'puter I was able to use Shutter Count, which now works w/ the 7D Mark II.

  • HT1420 How can I get a list of authorize computers under an Apple ID?

    How can I get a list of authorize computers under an Apple ID?
    How can I deauthorized a computers under an Apple ID if I do NOT have possession of that computer?
    Thanks
    -William

    It's not currently possible to see a list of authorised computers, but if you have 2 or more computers authorised then, as described on the page that you posted from, you can log into your account on your computer's iTunes (Store > View My Account, Store > View My Apple ID on iTunes 11) and 'deauthorise all' (which you can do once every 12 months) and you can then authorise/reauthorise the computers that you still have and need.
    Deauthorising a computer doesn't remove any content from it, it just means that you won't be able to use iTunes downloads on it until you reauthorise it

  • How can I get the DPI of the current workstation?

    Hi can anyone help me?
    I want to know the dpi witch is set on a Windows system.
    How can i get it? Because i will reformat and fit the dpi of displaying images to the dpi of a current window system, e.g image= 200x200dpi and monitor=84dpi so the dpi of the images should be set to 84.
    But How can i get the current dpi of the Workstation?
    please help,
    florian

    yes but it sucks because windows-workstations
    manipulates the dpi to a standard value of 96 dpi...
    its equal if there is a 15" or a 17" monitor ...
    thanks floI agree, getScreenResolution() just doesn't work. Try changing your screen resolution setting (say from 1024x768 to 800x600) and this method will continue to return the same value!
    Can one adjust the scale so that you can draw a 1 inch square, for instance? The default affine transform property of the graphics object passed to paint methods is supposed to have 72 units = 1 inch, but that's not true. Again, adjust your screen settings and the same 72x72 square will come out in very different sizes.
    Is there any way to correct this, short of going to native code to get the screen resolution? I know that the screen display may be a bit miscallibrated, but anything would be better that the way it is now!

  • How can I get log4j to write out to multiple logs?

    Hi,
    How can I get log4j to write out to multiple logs?
    Pls help me out.
    Thanks

    yawmark wrote:
    Harikesh wrote:
    Thanks@ gimbal2
    for giving valuable url.You should also type your question directly into Google. You might be pleasantly surprised by the results.
    ~Or not... [When tech support goes horribly wrong|http://www.cracked.com/video_16937_when-tech-support-goes-horribly-wrong.html] (cracked.com video)

  • How can we get the prompt to enter IP Address, Subnet Mask , gateway and DNS Server during Task Sequence?

    How can we get the prompt to enter IP Address, Subnet Mask , gateway and DNS Server during Task Sequence?

    This is for 2007 but may still be relevant for 2012
    http://hexdump.net/?p=391
    Cheers
    Paul | sccmentor.wordpress.com

  • HT1420 how can I get a list of the computers that are currently authorized?

    I need to authorize my home computer after switching from PC to Mac. How can I get a list of which devices are currently authorized?

    There is no list.

  • Network : How can I get  the name of all computers in the lan ?

    Hi.
    Network : How can I get the name or the IP of all computers in the lan ?

    Easiest way to find all IPs would be to scan the network. Ping every possible IP in the network and all IPs that replied to the ping exist.
    Since I don't know how to do a ping in Java, I would scan for some Ports used by OS Services.
    Since I don't know which ports are used by windows, I think you should look for a ping class (or library).
    Scanning all ports for every IP in a class C network shouldn't take too long. And after finding one port you don't have to try the other ports for that IP, since it has to be online ;)

  • HT1420 How can I get a list of authorized computers

    How do I get a list of the computers authorized to play iTunes music?

    There is no list available from your end.
    (77968)

  • How can I get a shutter count for my EOS1Ds Mark II?

    I am trying to get a shutter count for my EOS 1Ds MarkII in order to sell it, and buy a Mark III. Any ideas out there?
    Solved!
    Go to Solution.

    Click HERE
    EOS 1Ds Mk III, EOS 1D Mk IV EF 50mm f1.2 L, EF 24-70mm f2.8 L,
    EF 70-200mm f2.8 L IS II, Sigma 120-300mm f2.8 EX APO
    Photoshop CS6, ACR 9, Lightroom 6

  • How can I get the open counts on file type items?

    One of the managers' point of interesting on Portal usage is to know how frequently items are opened to view.
    I need to preapre a report to show managers which items (file type) are opened most frequently? and who opened the item most?
    How can I do it?
    Thanks,

    The Apple Support Communities are an international user to user technical support forum. As a man from Mexico, Spanish is my native tongue. I do not speak English very well, however, I do write in English with the aid of the Mac OS X spelling and grammar checks. I also live in a culture perhaps very very different from your own. When offering advice in the ASC, my comments are not meant to be anything more than helpful and certainly not to be taken as insults.
    Are you saying that you bought a used or second hand Mac? In North America an open box Mac usually refers to a display model used in a store.
    There is mixed info on this issue. Some folks in the US have called Apple Care and requested that the iLife apps prebundled with this specific Mac be released from original owner's Apple ID so the new owner can Accept the apps into their Apple ID, with success. Folks in Europe report that when making the same request of Apple Care they are met with resistance and are unsuccessful.
    YMMV
    The sad thing is that if Apple Care will not release the apps, then the owner of a second hand Mac cannot even purchaase the apps on their Mac! To buy the apps with their own account, they would need to find an older Mac running at least OS X Snow Leopard 10.6.8 with a Mac App Store (MAS), that also has never had the MAS versions of the iLife apps installed on it.

  • How can i get user to use my application without logging on as a developer?

    Hi
    Can anyone tell me or point me in the direction of information regarding allowing users to be pointed straight to an application on apex. Curently i log in via the apex.oracle.com home page use my database name then my username and password. But that only gets me in i want to allow user to be able to view and use the applications. How can i do this? Or is this indeeded possible i would assume that it is.
    thanks
    Dan Stead

    Dan,
    Another possibility is that if you host it yourself, or go with one of the production hosting companies then they can help you to configure it so that you can point a DNS name (e.g. www.yourapp.com) to point to your application, so that is all your users would need to enter into their browsers.
    You can find a list of hosting providers here -
    http://wiki.shellprompt.net/bin/view/Apex/HostingExamples
    (in the interests of disclosure, I run one of those companies on the list)

  • HT1420 how can i get a list or authorised computers

    Hi I see i has 5 computers listes as Authorized but only have 3 item Imac, Iphone and Ipad how can i check what the others are?

    I'm not aware that you can see a list of them anywhere - have you had other computers in the past and not deauthorised them and/or upgraded the OS on your iMac (the iPhone and iPad aren't computers) without deauthorising it first ? If you've reached the 5 computer limit then you can log into your account and 'deauthorise all' (which you can do once every 12 months) and you can then (re-)authorise the computers that you still have and need : authorising and deauthorising.

  • How can I get the username of the person currently logged in?

    I have built a custom authentication scheme and I am building a form page and I would like to show the username of the person who is currently logged in? How can I do this......

    Use the <tt>APP_USER</tt> built-in substitution string.
    This value can be referenced in various ways, including the static text exact substitution method <tt>&APP_USER.</tt> which can be used in page and region templates to display the current user name.

Maybe you are looking for

  • Exporting a 16:9 sequence always ends up 4:3?

    Hi - I use FCE HD and shoot anamorphic 16:9 widescreen. I capture in FCE, and edit it in 16:9 as FCE has corrected identified the clips as widescreen. However, if I export if to Quicktime Movie then it always loses the anamorphic and comes out at 4:3

  • Report using Custom Adapter

    I have a Flat File (csv) as a Resource Is there any way to generate the same file as report by customising the Adapter through Active Sync process. Can anybody help me in this regard....

  • Little security issue in password box on connections

    I'm on 1.2.0.29.98 on OSX. I have a password with an @ symbol in it. I was making a new connection in the connection dialog box and typed in the password wrong. I noticed when I double clicked the obfuscated password it only highlighted part of it to

  • ColorChecker Passport-Color Profiles

    Hi there, I am photographing paintings with Elinchrom flashes with an even light and I use the ColorChecker Passport from X-Rite to keep a reference in order to match the colors. Till now, I've been using the software DNG profile manager, provided wi

  • Select previlege on queuetable is a must ?

    Hi, I have an aq admin user ( aq_admin, who has been given the role of aq_administrator_role), I have two users aq_admin has a table ( test_queue_tab ) in its schema, in which queue1, and queue2( both are multi consumer queues) are present. I also ha