February 8, 2002 at 3:06 am
Does anyone know how to tell where a query to SQL Server 2000 originates. I have a system with a number of remote clients, and I need to know who is issuing certain queries.
Many thanks
Chris E
February 8, 2002 at 4:31 am
You could run Profiler to get HostName for sure and LoginName. I would capture HostName, LoginName, TextData, AplicationName and StartTime as the bare minimum. Also I have the output goto a table for easy reference later. But keep in mind there is some overhead in using Profiler that could impact you a bit and only run it until you find what you are looking for. FOr this the normal selected events on the events tab for the trace should be fine.
February 8, 2002 at 4:53 am
Many thanks for your reply,
Perhaps I should have made myself clearer :-
I can see who is issuing those queries with profiler, but I need to programatically see where a query comes from in T-SQL.
What I am trying to do is to return a results set in one of two languages (English or Spanish) depending on whether the client machine is currently using English or Spanish as its default language.
I have the language rountines setup and working, but haven't found yet a way of seeing which client is querying the server in realtime so that I can decide which language to respond in.
Any further suggestions appreciated...
Chris E
February 8, 2002 at 5:19 am
How about just passing a parameter in for Langauage? Or storing it when the user connects, then all other queries could join/select from the "config" table to set the language.
Andy
February 8, 2002 at 5:24 am
That is about the only way I see it can be done. Or if the client cannot do this for you and each person logs in uniquely you could create a cofig table that someone whould have to keep updating each time a new client comes in.
February 8, 2002 at 5:46 am
I considered pasing a language parameter, but the number of queries I would need to change is huge.
What I have at present is a table which holds a list of node names and the language which that node is set to. This table is updated as and when the language is changed on those nodes, which can be done instantly without reboot etc (this is a feature of the client software).
Now if I can detect which node is issuing a query, I can intercept it and decide to respond in English or Spanish by use of my node/language table.
What I am trying to do is save a lot of time and work, but I guess if I cannot detect the node without altering huge numbers of queries, I'll have to bite the bullet and work all weekend (and then some).
Any further thoughts ?
Cheers
Chris E
February 8, 2002 at 8:14 am
Not clear on why you have so much work to do. Regardless of where you get the value from you still have to do conditional execution, right? I think if you put the value in a config table and query that (or use a function) that makes your conditional logic about the same as if you had access to a system variable or table that told you the language.
Andy
February 13, 2002 at 8:27 am
Thanks for the suggestions chaps. I used the HOST_NAME() function in the end - works well.
Regards
Chris E
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply