Saturday, February 25, 2012

Machine Name In Trigger

Is it possible to get the machine name in a trigger so that it can be stored
in a field?

Thanks.Check out HOST_NAME() in the BOL.

--
Tom

----------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com
..
"Neil" <njones@.pxdy.com> wrote in message
news:N1vTd.5219$873.4670@.newsread3.news.pas.earthl ink.net...
Is it possible to get the machine name in a trigger so that it can be stored
in a field?

Thanks.|||Great. Thanks.

"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
news:OjjQtktGFHA.4032@.TK2MSFTNGP12.phx.gbl...
> Check out HOST_NAME() in the BOL.
> --
> Tom
> ----------------
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Columnist, SQL Server Professional
> Toronto, ON Canada
> www.pinnaclepublishing.com
> .
> "Neil" <njones@.pxdy.com> wrote in message
> news:N1vTd.5219$873.4670@.newsread3.news.pas.earthl ink.net...
> Is it possible to get the machine name in a trigger so that it can be
> stored
> in a field?
> Thanks.|||Any function for getting the current Windows user?

Thanks!

"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
news:OjjQtktGFHA.4032@.TK2MSFTNGP12.phx.gbl...
> Check out HOST_NAME() in the BOL.
> --
> Tom
> ----------------
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Columnist, SQL Server Professional
> Toronto, ON Canada
> www.pinnaclepublishing.com
> .
> "Neil" <njones@.pxdy.com> wrote in message
> news:N1vTd.5219$873.4670@.newsread3.news.pas.earthl ink.net...
> Is it possible to get the machine name in a trigger so that it can be
> stored
> in a field?
> Thanks.|||Check if this helps:

SELECT @.@.SPID AS 'ID', SYSTEM_USER AS 'Login Name', USER AS 'User Name'

--
HTH,
Vinod Kumar
MCSE, DBA, MCAD, MCSD
http://www.extremeexperts.com

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

"Neil" <njones@.pxdy.com> wrote in message
news:6_xTd.5362$873.4937@.newsread3.news.pas.earthl ink.net...
> Any function for getting the current Windows user?
> Thanks!
>
> "Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
> news:OjjQtktGFHA.4032@.TK2MSFTNGP12.phx.gbl...
> > Check out HOST_NAME() in the BOL.
> > --
> > Tom
> > ----------------
> > Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> > SQL Server MVP
> > Columnist, SQL Server Professional
> > Toronto, ON Canada
> > www.pinnaclepublishing.com
> > .
> > "Neil" <njones@.pxdy.com> wrote in message
> > news:N1vTd.5219$873.4670@.newsread3.news.pas.earthl ink.net...
> > Is it possible to get the machine name in a trigger so that it can be
> > stored
> > in a field?
> > Thanks.|||Here's what I got:

ID Login Name
User Name
-- ---------------------------------------
---------------------------------------9 sadbo(1 row(s) affected)I was looking for the Windows account that's currently logged in, if that'spossible.Thanks."Vinod Kumar" <vinodk_sct@.NO_SPAM_hotmail.com> wrote in messagenews:cvmtl9$ufs$1@.news01.intel.com...> Check if this helps:>> SELECT @.@.SPID AS 'ID', SYSTEM_USER AS 'Login Name', USER AS 'User Name'>> --> HTH,> Vinod Kumar> MCSE, DBA, MCAD, MCSD> http://www.extremeexperts.com>> Books Online for SQL Server SP3 at> http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp>> "Neil" <njones@.pxdy.com> wrote in message> news:6_xTd.5362$873.4937@.newsread3.news.pas.earthl ink.net...>> Any function for getting the current Windows user?>>>> Thanks!>>>>>> "Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message>> news:OjjQtktGFHA.4032@.TK2MSFTNGP12.phx.gbl...>> > Check out HOST_NAME() in the BOL.>> >>> > -->> > Tom>> >>> > ---------------->> > Thomas A. Moreau, BSc, PhD, MCSE, MCDBA>> > SQL Server MVP>> > Columnist, SQL Server Professional>> > Toronto, ON Canada>> > www.pinnaclepublishing.com>> > .>> > "Neil" <njones@.pxdy.com> wrote in message>> > news:N1vTd.5219$873.4670@.newsread3.news.pas.earthl ink.net...>> > Is it possible to get the machine name in a trigger so that it can be>> > stored>> > in a field?>> >>> > Thanks.>> >>> >>>>>>|||try suser_sname()

dean

"Neil" <njones@.pxdy.com> wrote in message
news:wGAUd.7684$873.5789@.newsread3.news.pas.earthl ink.net...
> Here's what I got:
> ID Login Name
> User Name
> -- --------------------
-------------------
> ----------------------
-----------------9 sadbo(1 row(s)
affected)I was looking for the Windows account that's currently logged in,
if that'spossible.Thanks."Vinod Kumar" <vinodk_sct@.NO_SPAM_hotmail.com>
wrote in messagenews:cvmtl9$ufs$1@.news01.intel.com...> Check if this
helps:>> SELECT @.@.SPID AS 'ID', SYSTEM_USER AS 'Login Name', USER AS 'User
Name'>> --> HTH,> Vinod Kumar> MCSE, DBA, MCAD, MCSD>
http://www.extremeexperts.com>> Books Online for SQL Server SP3 at>
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp>> "Neil"
<njones@.pxdy.com> wrote in message>
news:6_xTd.5362$873.4937@.newsread3.news.pas.earthl ink.net...>> Any function
for getting the current Windows user?>>>> Thanks!>>>>>> "Tom Moreau"
<tom@.dont.spam.me.cips.ca> wrote in message>>
news:OjjQtktGFHA.4032@.TK2MSFTNGP12.phx.gbl...>> > Check out HOST_NAME() in
the BOL.>> >>> > -->> > Tom>> >>>
> ---------------->> > Thomas A. Moreau,
BSc, PhD, MCSE, MCDBA>> > SQL Server MVP>> > Columnist, SQL Server
Professional>> > Toronto, ON Canada>> > www.pinnaclepublishing.com>> > .>>
> "Neil" <njones@.pxdy.com> wrote in message>news:N1vTd.5219$873.4670@.newsread3.news.pas.earthl ink.net...>> > Is it
possible to get the machine name in a trigger so that it can be>> > stored>>
> in a field?>> >>> > Thanks.>> >>> >>>>>>|||Neil (njones@.pxdy.com) writes:
> Here's what I got:
> ID Login Name
> User Name
>-----------------
>9 sadbo(1 row(s) affected)
>I was looking for the Windows account that's currently logged in, if
>that'spossible.

It appears that the user has logged in through SQL authentication. In
that case you cannot retrieve the Windows user. In fact, the user
may not even have been authenticated through Windows - he might be
accessing SQL Server from a Unix box.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Still get "sa".

"Dean" <dvitner@.nospam.gmail.com> wrote in message
news:uiV8mSZHFHA.2420@.TK2MSFTNGP14.phx.gbl...
> try suser_sname()
> dean
> "Neil" <njones@.pxdy.com> wrote in message
> news:wGAUd.7684$873.5789@.newsread3.news.pas.earthl ink.net...
>> Here's what I got:
>>
>> ID Login Name
>> User Name
>> -- --------------------
> -------------------
>> ----------------------
> -----------------9 sadbo(1
> row(s)
> affected)I was looking for the Windows account that's currently logged in,
> if that'spossible.Thanks."Vinod Kumar" <vinodk_sct@.NO_SPAM_hotmail.com>
> wrote in messagenews:cvmtl9$ufs$1@.news01.intel.com...> Check if this
> helps:>> SELECT @.@.SPID AS 'ID', SYSTEM_USER AS 'Login Name', USER AS 'User
> Name'>> --> HTH,> Vinod Kumar> MCSE, DBA, MCAD, MCSD>
> http://www.extremeexperts.com>> Books Online for SQL Server SP3 at>
> http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp>> "Neil"
> <njones@.pxdy.com> wrote in message>
> news:6_xTd.5362$873.4937@.newsread3.news.pas.earthl ink.net...>> Any
> function
> for getting the current Windows user?>>>> Thanks!>>>>>> "Tom Moreau"
> <tom@.dont.spam.me.cips.ca> wrote in message>>
> news:OjjQtktGFHA.4032@.TK2MSFTNGP12.phx.gbl...>> > Check out HOST_NAME() in
> the BOL.>> >>> > -->> > Tom>> >>>
>> ---------------->> > Thomas A.
>> Moreau,
> BSc, PhD, MCSE, MCDBA>> > SQL Server MVP>> > Columnist, SQL Server
> Professional>> > Toronto, ON Canada>> > www.pinnaclepublishing.com>> .>>
>> "Neil" <njones@.pxdy.com> wrote in message>> news:N1vTd.5219$873.4670@.newsread3.news.pas.earthl ink.net...>> > Is it
> possible to get the machine name in a trigger so that it can be>> stored>>
>> in a field?>> >>> > Thanks.>> >>> >>>>>>>
>>|||I was hoping there was a way to use a Windows API call or other, even with
SQL authentication.

Neil

"Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
news:Xns960C1AF7BCEYazorman@.127.0.0.1...
> Neil (njones@.pxdy.com) writes:
>> Here's what I got:
>>
>> ID Login Name
>> User Name
>>-----------------
>>9 sadbo(1 row(s) affected)
>>I was looking for the Windows account that's currently logged in, if
>>that'spossible.
> It appears that the user has logged in through SQL authentication. In
> that case you cannot retrieve the Windows user. In fact, the user
> may not even have been authenticated through Windows - he might be
> accessing SQL Server from a Unix box.
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techin.../2000/books.asp|||But how do you expect to get the Windows login when it is not a Windows
login in use but a SQL login? Do you mean the user account used on the
client (as opposed to the server)? If that's what you mean then you're
out of luck because SQL Server only knows what it's been told. That is,
the SQL Server doesn't really know anything about the client. As Erland
said, you don't even know what OS the client is running.

--
*mike hodgson* |/ database administrator/ | mallesons stephen jaques
*T* +61 (2) 9296 3668 |* F* +61 (2) 9296 3885 |* M* +61 (408) 675 907
*E* mailto:mike.hodgson@.mallesons.nospam.com |* W* http://www.mallesons.com

Neil wrote:

>I was hoping there was a way to use a Windows API call or other, even with
>SQL authentication.
>Neil
>"Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
>news:Xns960C1AF7BCEYazorman@.127.0.0.1...
>
>>Neil (njones@.pxdy.com) writes:
>>
>>
>>>Here's what I got:
>>>
>>>ID Login Name
>>>User Name
>>>-----------------
>>>9 sadbo(1 row(s) affected)
>>>I was looking for the Windows account that's currently logged in, if
>>>that'spossible.
>>>
>>>
>>It appears that the user has logged in through SQL authentication. In
>>that case you cannot retrieve the Windows user. In fact, the user
>>may not even have been authenticated through Windows - he might be
>>accessing SQL Server from a Unix box.
>>
>>--
>>Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
>>
>>Books Online for SQL Server SP3 at
>>http://www.microsoft.com/sql/techin.../2000/books.asp
>>
>>
>

No comments:

Post a Comment