Monday, March 26, 2012
How to get the REAL host name?
I need to be able to determine the name of the client machine running the
session. The value in sysprocesses.hostname is client-supplied, so it may be
not the real name of the client machine. The client can explicitly specify
any host name in the ADO connection string. Is there a way to find out the
real host name? Perhaps from the network adapter address, which is also in
sysprocesses?
This problem is especially apparent for MS Access projects (adp's); they
always connect with the host name being the name of the developer's machine.
thanks,
VadimYou tocuhed on the answer... I'm sure there's a way to get it from the MAC
address. I just don't know TCP enough to tell you how...
but there's nothing else that could definitiely tell you. As you point
out... the client can put anything it wants int he string...
--
Brian Moran
Principal Mentor
Solid Quality Learning
SQL Server MVP
http://www.solidqualitylearning.com
"Vadim Rapp" <vr@.myrealbox.nospam.com> wrote in message
news:u5zReG7rDHA.1760@.TK2MSFTNGP10.phx.gbl...
> Hello:
> I need to be able to determine the name of the client machine running the
> session. The value in sysprocesses.hostname is client-supplied, so it may
be
> not the real name of the client machine. The client can explicitly specify
> any host name in the ADO connection string. Is there a way to find out the
> real host name? Perhaps from the network adapter address, which is also in
> sysprocesses?
> This problem is especially apparent for MS Access projects (adp's); they
> always connect with the host name being the name of the developer's
machine.
> thanks,
> Vadim
>|||Depending on the architecture of TDS, which I'm not sure of, the MAC address
may not be the client's host NIC anyway, usually MAC address is the address
of the client NIC or the nearest router NIC whichever is logically closer on
the network.
But, it you want to assume MAC=MAC of Client NIC, you could write a routine
to parse the output of ARP -a
Kevin Connell, MCDBA
----
The views expressed here are my own
and not of my employer.
----
"Brian Moran" <brian@.solidqualitylearning.com> wrote in message
news:uC#7f47rDHA.3552@.TK2MSFTNGP11.phx.gbl...
> You tocuhed on the answer... I'm sure there's a way to get it from the MAC
> address. I just don't know TCP enough to tell you how...
> but there's nothing else that could definitiely tell you. As you point
> out... the client can put anything it wants int he string...
> --
> Brian Moran
> Principal Mentor
> Solid Quality Learning
> SQL Server MVP
> http://www.solidqualitylearning.com
>
> "Vadim Rapp" <vr@.myrealbox.nospam.com> wrote in message
> news:u5zReG7rDHA.1760@.TK2MSFTNGP10.phx.gbl...
> > Hello:
> >
> > I need to be able to determine the name of the client machine running
the
> > session. The value in sysprocesses.hostname is client-supplied, so it
may
> be
> > not the real name of the client machine. The client can explicitly
specify
> > any host name in the ADO connection string. Is there a way to find out
the
> > real host name? Perhaps from the network adapter address, which is also
in
> > sysprocesses?
> >
> > This problem is especially apparent for MS Access projects (adp's); they
> > always connect with the host name being the name of the developer's
> machine.
> >
> > thanks,
> >
> > Vadim
> >
>
Monday, March 12, 2012
How to get rowcount
Hi,
How to get the row count for a particular query being executed within a session and scope. is there any option to get the value being displayed in the messages tab when a query is executed (no of rows affected). is there anything equivalent to scope_identity for getting the identity value inserted in a session and scope.
Vivek S
to obtain number of rows affected...
@.@.RowCount (return an int)
RowCount_Big() (return a big int)
to obtain last genereted identiy value...
@.@.IDENTITY, SCOPE_IDENTITY, and IDENT_CURRENT are similar functions because they all return the last value inserted into the IDENTITY column of a table.
@.@.IDENTITY and SCOPE_IDENTITY return the last identity value generated in any table in the current session. However, SCOPE_IDENTITY returns the value only within the current scope; @.@.IDENTITY is not limited to a specific scope.
IDENT_CURRENT is not limited by scope and session; it is limited to a specified table. IDENT_CURRENT returns the identity value generated for a specific table in any session and any scope. For more information, see IDENT_CURRENT (Transact-SQL).
The scope of the @.@.IDENTITY function is current session on the local server on which it is executed. This function cannot be applied to remote or linked servers. To obtain an identity value on a different server, execute a stored procedure on that remote or linked server and have that stored procedure (which is executing in the context of the remote or linked server) gather the identity value and return it to the calling connection on the local server.
|||did this help?