|
Hi everyone! I need to get a list of users connected to a database. I want to implement a fuctionality in my application that allows users connected to the database to communicate. For instance one administrator in his office can request or send information to another in an office through the network.
A user executing 'select * from master..sysprocesses' does not show all connected users but only the one executing the command. How do I get users to view list of connected users so that they select the one they need to communicate with? I'm using Sql Server 2005. Thanks in advance.
|
|
|
|
|
I'm not sure, but I believe that you need to be a sysadmin member to view which other users are connected. Since you (probably) will not promote every user to an admin, I'd suggest rolling your own. It's quite easy to create a table with a username and a datetime of login. Insert the users' name when he/she logs in, delete it if they logout or are inactive for a specified period of time.
Bastard Programmer from Hell
|
|
|
|
|
You can look at these commands, but I beleive you need elevated permissions to see other people on the server.
Maybe you could write a web service that connects to the database with Admin privs and returns the list of users for each request. This would allow you current user configuration no to change, just some additional functionality would be published.
Just a thought.
Remeber to vote.
|
|
|
|
|
Thanks David and Eddy. I got the solution. It is done by executing 'GRANT VIEW SERVER STATE TO [LOGIN]' at the server scope. It works now.
|
|
|
|
|
Hi,
I want to secure a database in SQL Server 2008. Here is the situation description:
I am using both 'windows' and 'sa' authentication. When I create a database (logged as 'windows' authenticated) I can see and change it (create tables, stored procedures) from logged as 'sa' authentication or vice versa. So, there is no difference whether I create it logged as 'windows' or 'sa'. But, what I need is to secure a particular database i.e. even if I am logged as 'windows' I want the particular database to be accessed only by providing a username and password.
Do you have any idea how to resolve this?
modified 25-Jun-12 6:29am.
|
|
|
|
|
Can't be done; the Administrator of the local computer is considered to be the owner of his/her data.
Alternatively, you might consider another database, or hosting your server on a different machine than the users'.
Bastard Programmer from Hell
|
|
|
|
|
Can you give any details (how to consider another database)?
|
|
|
|
|
Kujtim Hyseni wrote: Can you give any details (how to consider another database)?
A comparison on databases can be found here[^]. Both MySQL and Oracle provide free alternatives that may fit your requirements.
Bastard Programmer from Hell
|
|
|
|
|
You didn't provided solution, that is just an article of capabilities. I need short and precise guide. By the way, I don't use MySQL nor Oracle.
|
|
|
|
|
Kujtim Hyseni wrote: You didn't provided solution, that is just an article of capabilities.
I don't have to provide a solution. I'm not at work, this 'advice' is being given in my own spare time. I could be doing something productive, like the dishes, but I had chosen to answer this question. Might benefit someone, and I'm sure the dishes do not mind waiting
Kujtim Hyseni wrote: I need short and precise guide.
You already have - it's called the documentation[^]. Right on the first lines, it states short and precise;
There are two possible modes: Windows Authentication mode and mixed mode.
Kujtim Hyseni wrote: By the way, I don't use MySQL nor Oracle.
They were provided as alternative solutions to your problem.
I'm not going to provide any further pointers, as doing the dishes seems like a more important task suddenly.
Bastard Programmer from Hell
|
|
|
|
|
Doing dishes is definitely underrated.
|
|
|
|
|
Why don't you just limit access?
The database server should be on a secured box anyways and logins to that box should be limited to only a few people in the organization.
All other access to the database are via login credentials.
|
|
|
|
|
Hi,
I have to convert Sql Query Result Into Report like crystal report or pdf format.
Suppose I run query
select EmpName, EmpDepartment from MasterDepartment.
EmpName EmpDepartment
Rakesh IT
Shirish IT
Shalu HR
This way I want to print in PDF file
|
|
|
|
|
thakrerakesh wrote: This way I want to print in PDF file
Then you need to use some library to produce the PDF output; take a look at iTextSharp[^].
|
|
|
|
|
if i apply a NOLOCK on one table in a Stored Procedure then will it be applicable to all other tables consumed in that Stored Procedure too automatically
- Happy Coding -
Vishal Vashishta
|
|
|
|
|
|
Ok ... but can you make me clear little bit more about the NOLOCK concept,any article you want to refer.?
- Happy Coding -
Vishal Vashishta
|
|
|
|
|
Sorry to take so long to get back with you but I was on vacation.
Take a look at:
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
Since NOLOCK is a 'hint' it is only for the one command.
|
|
|
|
|
I have a table in SQL Server 2008 like this:
EventID UserID State
1 0987 A
2 0987 A
3 0987 B
4 0956 A
5 0987 A
6 0019 A
7 0019 B
8 1289 B
9 1289 B
10 0019 A
I want to get some results from this table in such form:
UserID StateCount_of_A StateCount_of_B
0987 3 1
0019 2 1
1289 0 2
0956 1 0
I have try a few days, but I could get a disappointed result for ony one UserID. My result likes this one, for example with UserID 0987:
StateCount_of_A 3
StateCount_of_B 1
Thanks for anyone who could give me some tip.
|
|
|
|
|
Try ...
Select EventID,(select count(*) from <myeventtable> E2 where E1.EventID = E2.EventID) As Count_of_A, (select count(*) from <myeventtable> E3 where E1.EventID = E3.EventID) As Count_of_B,
from <myeventtable> E1
Remeber to Vote.
|
|
|
|
|
You seemed to have picked up a stalker or someone objects to the unformatted code or you are getting a reaction to your sig!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I haven't tried this, however my first try would look like this:
SELECT DISTINCT UserID, StateCount_of_A, StateCount_of_B FROM tablename AS T1
LEFT JOIN (SELECT UserID, COUNT(*) AS StateCount_of_A FROM tablename AS TA WHERE State='A') ON TA.UserID = T1.UserID
LEFT JOIN (SELECT UserID, COUNT(*) AS StateCount_of_B FROM tablename AS TB WHERE State='B') ON TB.UserID = T1.UserID
ORDER BY UserID
(Actually I would try a subset of it with a single state first, then expand for the exact requirements).
The fundamental trick is to use the same table more than once, and give each "instance" a different name using the AS keyword.
And then one might have to throw in a couple of COALESCE functions to replace null counts by zeroes.
|
|
|
|
|
SELECT UserId
,SUM(StateA) StateCount_of_A
,SUM(StateB) StateCount_of_B
FROM (
SELECT UserId
,CASE WHEN [State]='A' THEN 1 ELSE 0 END StateA
,CASE WHEN [State]='B' THEN 1 ELSE 0 END StateB
FROM Junk
) T
GROUP BY UserID
|
|
|
|
|
Hello,
I cannot register new server in SQL Server 2008. I can save it but cannot start all the items (Start, Stop, ...) under Service Control menu appear disabled.
|
|
|
|
|
Kujtim Hyseni wrote: I cannot register new server in SQL Server 2008
What does that mean exactly?
Are you saying that you INSTALLED sql server and start is not enabled in the windows services control panel applet?
|
|
|
|