Machine Name In Trigger

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Neil

    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.


  • Tom Moreau

    #2
    Re: Machine Name In Trigger

    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

    ..
    "Neil" <njones@pxdy.co m> wrote in message
    news:N1vTd.5219 $873.4670@newsr ead3.news.pas.e arthlink.net...
    Is it possible to get the machine name in a trigger so that it can be stored
    in a field?

    Thanks.


    Comment

    • Neil

      #3
      Re: Machine Name In Trigger

      Great. Thanks.

      "Tom Moreau" <tom@dont.spam. me.cips.ca> wrote in message
      news:OjjQtktGFH A.4032@TK2MSFTN GP12.phx.gbl...[color=blue]
      > 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.co m> wrote in message
      > news:N1vTd.5219 $873.4670@newsr ead3.news.pas.e arthlink.net...
      > Is it possible to get the machine name in a trigger so that it can be
      > stored
      > in a field?
      >
      > Thanks.
      >
      >[/color]


      Comment

      • Neil

        #4
        Re: Machine Name In Trigger

        Any function for getting the current Windows user?

        Thanks!


        "Tom Moreau" <tom@dont.spam. me.cips.ca> wrote in message
        news:OjjQtktGFH A.4032@TK2MSFTN GP12.phx.gbl...[color=blue]
        > 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.co m> wrote in message
        > news:N1vTd.5219 $873.4670@newsr ead3.news.pas.e arthlink.net...
        > Is it possible to get the machine name in a trigger so that it can be
        > stored
        > in a field?
        >
        > Thanks.
        >
        >[/color]


        Comment

        • Vinod Kumar

          #5
          Re: Machine Name In Trigger

          Check if this helps:

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

          --
          HTH,
          Vinod Kumar
          MCSE, DBA, MCAD, MCSD


          Books Online for SQL Server SP3 at
          Get the flexibility you need to use integrated solutions, apps, and innovations in technology with your data, wherever it lives—in the cloud, on-premises, or at the edge.


          "Neil" <njones@pxdy.co m> wrote in message
          news:6_xTd.5362 $873.4937@newsr ead3.news.pas.e arthlink.net...[color=blue]
          > Any function for getting the current Windows user?
          >
          > Thanks!
          >
          >
          > "Tom Moreau" <tom@dont.spam. me.cips.ca> wrote in message
          > news:OjjQtktGFH A.4032@TK2MSFTN GP12.phx.gbl...[color=green]
          > > 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.co m> wrote in message
          > > news:N1vTd.5219 $873.4670@newsr ead3.news.pas.e arthlink.net...
          > > Is it possible to get the machine name in a trigger so that it can be
          > > stored
          > > in a field?
          > >
          > > Thanks.
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • Neil

            #6
            Re: Machine Name In Trigger

            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.co m> wrote in messagenews:cvm tl9$ufs$1@news0 1.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.extremeexpe rts.com>> Books Online for SQL Server SP3 at> http://www.microsoft.c om/sql/techinfo/productdoc/2000/books.asp>> "Neil" <njones@pxdy.co m> wrote in message> news:6_xTd.5362 $873.4937@newsr ead3.news.pas.e arthlink.net... >> Any function for getting the current Windows user?>>>> Thanks!>>>>>> "Tom Moreau" <tom@dont.spam. me.cips.ca> wrote in message>> news:OjjQtktGFH A.4032@TK2MSFTN GP12.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.pinnaclepub lishing.com>> > .>> > "Neil" <njones@pxdy.co m> wrote in message>> > news:N1vTd.5219 $873.4670@newsr ead3.news.pas.e arthlink.net... >> > Is it possible to get the machine name in a trigger so that it can be>> > stored>> > in a field?>> >>> > Thanks.>> >>> >>>>>>>

            Comment

            • Dean

              #7
              Re: Machine Name In Trigger

              try suser_sname()

              dean

              "Neil" <njones@pxdy.co m> wrote in message
              news:wGAUd.7684 $873.5789@newsr ead3.news.pas.e arthlink.net...[color=blue]
              > Here's what I got:
              >
              > ID Login Name
              > User Name
              > ------ -------------------------------------------------------------------[/color]
              -------------------------------------------------------------[color=blue]
              > -------------------------------------------------------------------------[/color]
              -------------------------------------------------------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.co m>
              wrote in messagenews:cvm tl9$ufs$1@news0 1.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.extremeexpe rts.com>> Books Online for SQL Server SP3 at>
              http://www.microsoft.c om/sql/techinfo/productdoc/2000/books.asp>> "Neil"
              <njones@pxdy.co m> wrote in message>
              news:6_xTd.5362 $873.4937@newsr ead3.news.pas.e arthlink.net... >> Any function
              for getting the current Windows user?>>>> Thanks!>>>>>> "Tom Moreau"
              <tom@dont.spam. me.cips.ca> wrote in message>>
              news:OjjQtktGFH A.4032@TK2MSFTN GP12.phx.gbl... >> > Check out HOST_NAME() in
              the BOL.>> >>> > -->> > Tom>> >>>[color=blue]
              > ---------------------------------------------------->> > Thomas A. Moreau,[/color]
              BSc, PhD, MCSE, MCDBA>> > SQL Server MVP>> > Columnist, SQL Server
              Professional>> > Toronto, ON Canada>> > www.pinnaclepub lishing.com>> > .>>[color=blue]
              > "Neil" <njones@pxdy.co m> wrote in message>> >[/color]
              news:N1vTd.5219 $873.4670@newsr ead3.news.pas.e arthlink.net... >> > Is it
              possible to get the machine name in a trigger so that it can be>> > stored>>[color=blue]
              > in a field?>> >>> > Thanks.>> >>> >>>>>>>
              >[/color]


              Comment

              • Erland Sommarskog

                #8
                Re: Machine Name In Trigger

                Neil (njones@pxdy.co m) writes:[color=blue]
                > 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 .[/color]

                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@sommarsk og.se

                Books Online for SQL Server SP3 at
                Get the flexibility you need to use integrated solutions, apps, and innovations in technology with your data, wherever it lives—in the cloud, on-premises, or at the edge.

                Comment

                • Neil

                  #9
                  Re: Machine Name In Trigger

                  Still get "sa".


                  "Dean" <dvitner@nospam .gmail.com> wrote in message
                  news:uiV8mSZHFH A.2420@TK2MSFTN GP14.phx.gbl...[color=blue]
                  > try suser_sname()
                  >
                  > dean
                  >
                  > "Neil" <njones@pxdy.co m> wrote in message
                  > news:wGAUd.7684 $873.5789@newsr ead3.news.pas.e arthlink.net...[color=green]
                  >> Here's what I got:
                  >>
                  >> ID Login Name
                  >> User Name
                  >> ------ -------------------------------------------------------------------[/color]
                  > -------------------------------------------------------------[color=green]
                  >> -------------------------------------------------------------------------[/color]
                  > -------------------------------------------------------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.co m>
                  > wrote in messagenews:cvm tl9$ufs$1@news0 1.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.extremeexpe rts.com>> Books Online for SQL Server SP3 at>
                  > http://www.microsoft.c om/sql/techinfo/productdoc/2000/books.asp>> "Neil"
                  > <njones@pxdy.co m> wrote in message>
                  > news:6_xTd.5362 $873.4937@newsr ead3.news.pas.e arthlink.net... >> Any
                  > function
                  > for getting the current Windows user?>>>> Thanks!>>>>>> "Tom Moreau"
                  > <tom@dont.spam. me.cips.ca> wrote in message>>
                  > news:OjjQtktGFH A.4032@TK2MSFTN GP12.phx.gbl... >> > Check out HOST_NAME() in
                  > the BOL.>> >>> > -->> > Tom>> >>>[color=green]
                  >> ---------------------------------------------------->> > Thomas A.
                  >> Moreau,[/color]
                  > BSc, PhD, MCSE, MCDBA>> > SQL Server MVP>> > Columnist, SQL Server
                  > Professional>> > Toronto, ON Canada>> > www.pinnaclepub lishing.com>> >
                  > .>>[color=green]
                  >> "Neil" <njones@pxdy.co m> wrote in message>> >[/color]
                  > news:N1vTd.5219 $873.4670@newsr ead3.news.pas.e arthlink.net... >> > Is it
                  > possible to get the machine name in a trigger so that it can be>> >
                  > stored>>[color=green]
                  >> in a field?>> >>> > Thanks.>> >>> >>>>>>>
                  >>[/color]
                  >
                  >[/color]


                  Comment

                  • Neil

                    #10
                    Re: Machine Name In Trigger

                    I was hoping there was a way to use a Windows API call or other, even with
                    SQL authentication.

                    Neil

                    "Erland Sommarskog" <esquel@sommars kog.se> wrote in message
                    news:Xns960C1AF 7BCEYazorman@12 7.0.0.1...[color=blue]
                    > Neil (njones@pxdy.co m) writes:[color=green]
                    >> 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'spossibl e.[/color]
                    >
                    > 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@sommarsk og.se
                    >
                    > Books Online for SQL Server SP3 at
                    > http://www.microsoft.com/sql/techinf...2000/books.asp[/color]


                    Comment

                    • Mike Hodgson

                      #11
                      Re: Machine Name In Trigger

                      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.hod gson@mallesons. nospam.com |* W* http://www.mallesons.com



                      Neil wrote:
                      [color=blue]
                      >I was hoping there was a way to use a Windows API call or other, even with
                      >SQL authentication.
                      >
                      >Neil
                      >
                      >"Erland Sommarskog" <esquel@sommars kog.se> wrote in message
                      >news:Xns960C1A F7BCEYazorman@1 27.0.0.1...
                      >
                      >[color=green]
                      >>Neil (njones@pxdy.co m) writes:
                      >>
                      >>[color=darkred]
                      >>>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'spossib le.
                      >>>
                      >>>[/color]
                      >>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@sommarsk og.se
                      >>
                      >>Books Online for SQL Server SP3 at
                      >>http://www.microsoft.com/sql/techinf...2000/books.asp
                      >>
                      >>[/color]
                      >
                      >
                      >
                      >[/color]

                      Comment

                      Working...