How to obtain a variable Server Account Name using an @SQl with an @variable_server_ name + 'master.dbo.xp.instance.regread ...'

Hi,
I am trying to make a flexible script to get the Service Account Name from several servers.
I am using "servername.master.dbo.xp_instance_regread.......", but I want to use a variable for the servername.
So I started doing this:
Declare @servername varchar(100)
Declare @SQL varchar(1000)
Declare @agtServAccName varchar(250)
set @servername = 'Server1'
set @sql = @servername + '.master.dbo.xp_instance_regread
N''HKEY_LOCAL_MACHINE'',
N""SYSTEM\CurrentControlSet\Services\SQLSERVERAGENT'',
N''ObjectName'',
@AgtServAccName Output,
N''no_output'''
Execute (@SQL) 
How am I able to get a flexible script (@sql), which gives me the Service Account Name of the server called @servername after I execute this script (@sql)
If there is another way without this regread, I like to hear that too ofcourse...
EDIT: the reason I use a variable for the servicename is, that I am running it on a central management server and not on the server with this servername itself.

This did the trick. Now I can loop through all my centrally managed servers and obtain the Service Account Names.
Thanks for the help. There's probably a better way to do it (sp_executesql?) , but at least I got something.
Declare @ServerName varchar(50)
Declare @SQL as varchar(500)
If object_id('tempdb..#ServAccName') is not null
drop table #ServAccName;
create table #ServAccName (ServAccName varchar(50))
set @ServerName = 'Server1'
set @SQL = '
declare @ServAccName varchar(50)
  execute ' + @ServerName + '.master.dbo.xp_instance_regread
                   HKEY_LOCAL_MACHINE,
                   ''SYSTEM\CurrentControlSet\Services\MSSQLServer'',
                  ObjectName,
                  @ServAccName OUTPUT
Insert #ServAccName Select @ServAccName
Exec (@SQL)
Select ServAccName from #ServAccName

Similar Messages

  • How to configure Oracle 10g Advanced Security to use SSL concurrently with

    How to configure Oracle 10g Advanced Security to use SSL concurrently with database User names and passwords
    In Oracle Advanced Security Documentation it is mentioned that i can use SSL concurrently with DB user names and passwords. But when i configure the client certificate on the client my DB connection is getting authenticated using the certificate, which out passing user id or password.
    We want to connect to Oracle DB over SSL channel so that the data packets are not in clear text. Also we want the user to make a connection using user id and password.
    Basically we want SSL with out authentication.
    Need your expert advice

    Read the documentation (I have given following links assuming you are running a 32 bit architecture)
    Server installations:
    http://www.oracle.com/pls/db102/to_toc?pathname=install.102%2Fb14316%2Ftoc.htm&remark=portal+%28Books%29
    Client installations:
    http://www.oracle.com/pls/db102/to_toc?pathname=install.102%2Fb14312%2Ftoc.htm&remark=portal+%28Books%29
    You can find the required books (if not using 32 bit architecture) from
    http://www.oracle.com/pls/db102/portal.portal_db?selected=3

  • A very simple question: how to obtain the mail server name?

    In our JSP application, at one point an email will be sent to notify one event. Currently, that is done by using the html tag: mailto. To have more control on the email in tems of context format (a bad layout right now) and others. I would like to have it processed at servlet by using the JavaMail API, so that it have a nice format and have the sender's email address right in case email client is not installed in the machine where the browser in. The JavaMail API is straight forward. The question is how to obtain the mail server name, and the sender's email address if there is one?
    Thanks.
    v.

    How to obtain the mail server's name? It's your server, you should know its name. Or if it isn't your server, you should ask the administrator for its name. Point is, you need to decide in advance what server you are going to use and hard-code its name into the program or into a properties file.
    And how to obtain the client's e-mail address? You have to ask the client, probably by putting a box in the HTML and asking them to type it.

  • How to  obtain last date of accounting period mmyyyy

    how to  obtain last date of accounting period mmyyyy.
    for ex: 31 st is the last date then output should be mm/31/yy.

    hi use this ....
    REPORT  ZTESTS.
    data: date1(4),
          date2(2),
          date3(2),
          date type sy-datum,
          output(8).
    parameters:p_date type sy-datum.
    CALL FUNCTION 'JVA_LAST_DATE_OF_MONTH'
      EXPORTING
        year_month               = p_date+0(6)
    IMPORTING
       LAST_DATE_OF_MONTH       =  date.
    output0(2) = date4(2).
    output+2(1) = '/'.
    output3(2) = date6(2).
    output+5(1) = '/'.
    output6(2) = date2(2).
    write:/ output.
    regards,
    venkat.

  • SQL Server cannot authenticate using Kerberos because the Service Principal Name (SPN) is missing, misplaced, or duplicated

    We are getting this below alert message, while using SCOM 2012 R2.  Anybody have any idea how to resolve this on the SQL box ?
    Thx...
    SQL Server cannot authenticate using Kerberos because the Service Principal Name (SPN) is missing, misplaced, or duplicated.
    Service Account: NT Service\MSSQL$SQLEXPRESS
    Missing SPNs:
    Misplaced SPNs: MSSQLSvc/mysqlbox.com:SQLEXPRESS - sqldbadmin
    Duplicate SPNs:

    To Fix this issue, You can check below links
    http://support.microsoft.com/kb/2443457/EN-US
    http://www.scomgod.com/?p=155
    Please remember, if you see a post that helped you please click "Vote As Helpful" and if it answered your question, please click "Mark As Answer"Mai Ali | My blog:
    Technical | Twitter:
    Mai Ali

  • How do I remove an iCloud account without using password?

    How do I remove an iCloud account without using password?

    There is no way if Find my iPhone is turned on. You must know the Apple ID and password. This is Activation Lock, an antitheft feature of iOS 7. See: http://support.apple.com/kb/HT5818

  • HT203052 How do I delete an icloud account which uses an email account no longer in use - I do not have the the passwrd for this account

    How do I delete an icloud account which uses an email account no longer in use - I do not have the the passwrd for this account

    You will need the password. If you can't get it reset via http://iforgot.apple.com (if you remember the answers to the account's security questions then you should be able to reset it via them) then try contacting Support in your country, they should be able to reset it.
    Contacting Apple about account security : http://support.apple.com/kb/HT569
    If your country isn't on that page then try this form and explain and see what they reply with : https://ssl.apple.com/emea/support/itunes/contact.html

  • How can i see if other accounts on my ipod touch with the serial code?

    How can i see if other accounts on my ipod touch with the serial code?

    What? If other accounts what?

  • How to set a variable in portal session using web dynpro java.

    Hi,
    I have created a web dynpro application, which is running inside portal. I have created a role called "R1". Inside role R1, i have created 3 workset W1, W2 and W3. and inside each workset i have some pages and iviews.
    My requirement is when user logins to the portal , and when he clicks on role R1 for the first time, a login page should come (so that we can do revalidation), and when he enters his password again in that login page , then only workset W1, W2 and W3 should be visible/accessible to him and after successful revalidation, if he clicks again on role R1, in that particular portal session, than that login page should not come.
    for this, i thought i will set a variable in portal session, whenever user successfully revalidated himself, and if after successful revalidation he clicks again on role R1, i will check in doinit method of webdynpro whether variable is set or not (which i already set on successful revalidation), and if it is set then i will do Donavigation else i will present login page to the user.
    Can anyone tells me how to set a variable in portal session using web dynpro java.
    thanks
    Arush

    Hi,
    Try this:
    WDScopeUtil.put(WDScopeType.CLIENTSESSION_SCOPE, key, value)
    WDScopeUtil.get(WDScopeType.CLIENTSESSION_SCOPE, key)
    Ex:
    WDScopeUtil.put(WDScopeType.CLIENTSESSION_SCOPE,"Key1","Value1");
    String value1=WDScopeUtil.get(WDScopeType.CLIENTSESSION_SCOPE,"Key1").toString();
    /people/william.cui/blog/2007/02/12/sharing-session-context-between-parent-and-external-windows-running-on-same-host
    Regards,
    Charan

  • How to reset the wiki server (MAC OS X 10.9 with OS X Server App Version 3) with all wiki datas only

    Hi,
    I need to reset my Wiki on MAC OS X 10.9 with OS X Server App Version 3, but without reinstalling the whole server app to configure all services.
    Does anybody knows how to reset the wiki server (MAC OS X 10.9 with OS X Server App Version 3) with all wiki datas only.
    Thanks a lot for your hints

    Hi Linc,
    sorry, I haven't saved the System-Logfile before restoring my parallels VM.
    But it looks like issues of linking data.
    For testing the Server services I have done a reset for a user password and I have deleted the profiles and configuration from Client-Side. One with Mac OS X 10.9.1, one iPad with iOS 6.1.3. But it was not possible to reconfigure/reinstall the Server Profile. Also a manually configuration was odd, because for some services the new password was necessary and for other services the old password. Very strange.
    To bring back the services I have rolled back the last snapshot of my parallels VM. Afterwards there was no probleme to reconfigure/reinstall the Profile on Client-Side (OS X 10.9.1 and iOS 6.1.3). Also the manually configuration shows the password for all services are matching with the current configuration.
    I'm going to install a further parallels VM with Mac OS X 10.9.1 and Server App 3 from scratch to move the services.
    Greetings

  • I have just pard a new i phone 4s with my mac OSX,the calender is not paring its stay at aseting saying moving calender to server account.I have focet quet with now result it just stay the same

    I have just pard a new i phone 4s with my mac OSX,the calender is not paring its stay at aseting saying moving calender to server account.I have focet quet with now result it just stay the same

    I have just pard a new i phone 4s with my mac OSX,the calender is not paring its stay at aseting saying moving calender to server account.I have focet quet with now result it just stay the same

  • Trying to install WSUS role on Windows Server 2012 R2 using dedicated SQL Instance with static port on remote SQL Server 2012 SP1 CU7 on Windows Server 2012 R2.

    I am trying to install WSUS role on Windows Server 2012 R2 using dedicated SQL Instance with static port on remote SQL Server 2012 SP1 CU7 on Windows Server 2012 R2.
    It verifies the connection and then throws the error:
    The request to add or remove features on the specified server failed. The operation cannot be completed, because the server you specified requires a restart.
    WSUS Server : Windows Server 2012 R2
    Remote SQL Server: 2012 SP1 CU7 hosted on Windows Server 2012 R2
    Please let me know if anyone has experienced this issue.

    We were trying to install WSUS role on Windows Server 2012 R2 using dedicated SQL Instance with static port on remote SQL Server 2012 SP1 CU7 on Windows Server 2012 R2.
    It verifies the connection and then throws the error:
    The request to add or remove features on the specified server failed. The operation cannot be completed, because the server you specified requires a restart.
    Same error even after rebooting the server multiple times.
    WSUS Server : Windows Server Standard2012 R2
    Remote SQL Server: Windows Server 2012 SP1 CU7 hosted on Windows Server 2012 R2
    Event ID 7000:
    The Windows Internal Database service failed to start due to the following error:
    The service did not start due to a logon failure.
    Event ID 7041
    The MSSQL$MICROSOFT##WID service was unable to log on as NT SERVICE\MSSQL$MICROSOFT##WID with the currently configured password due to the following error:
    Logon failure: the user has not been granted the requested logon type at this computer.
    Service: MSSQL$MICROSOFT##WID
    Domain and account: NT SERVICE\MSSQL$MICROSOFT##WID
    This service account does not have the required user right "Log on as a service."
    User Action
    Assign "Log on as a service" to the service account on this computer. You can use Local Security Settings (Secpol.msc) to do this. If this computer is a node in a cluster, check that this user
    right is assigned to the Cluster service account on all nodes in the cluster.
    If you have already assigned this user right to the service account, and the user right appears to be removed, check with your domain administrator to find out if a Group Policy object associated
    with this node might be removing the right.
    I found following article:
    "MSSQL$MICROSOFT##WID service was unable to log on as NT SERVICE\MSSQL$MICROSOFT##WID" error when you install WID in Windows Server 2012
    http://support.microsoft.com/kb/2832204/en-us
    To work around the issue, use one of the following methods:
    Assign the Log on as a service user right to NT SERVICE\ALL SERVICES in the GPO that defines the user right.
    Exclude the computer from the GPO that defines the user right.
    We moved the SCCM server to OU where no policies were getting applied and then applied the new GPO to that OU. Restarted the server and we were able to install WSUS role.
    Regards
    PR

  • How to read XML message present in Table using PL/SQL?

    Hi,
    How to read XML content present in Table using PL/SQL .And is it possible to parse the xml uisng xslt and insert xml output in same table again ?
    Thanks!

    Late reply, but hopefully better late than never.
    You can possibly do it all via a single SQL statement, such as {message:id=4232077}
    XMLTable Syntax can be found at http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions228.htm#CIHGGHFB (for 10.2 users) else find your correct version at http://www.oracle.com/technology/documentation/index.html

  • How can I create an csv/excel file using pl/sql and then sending that file

    How can I create an csv/excel file using pl/sql and then sending that file to a clients site using pl/sql?
    I know how to create the csv/excel file but I can't figure out how I would get it to the clients site.

    968776 wrote:
    How can I create an csv/excel file using pl/sql and then sending that file to a clients site using pl/sql?
    I know how to create the csv/excel file but I can't figure out how I would get it to the clients site.You are trying to do it at a wrong place..
    Whay do you want database (pl/sql) code to do these things?
    Anyhow, you may be interested in :
    {message:id=9360007}
    {message:id=9984244}

  • How do I install 10.9.1 directly using an Air with 10.6.8 Snow Leopard?

    How do I install 10.9.1 directly using an Air with 10.6.8 Snow Leopard? My friend shared a copy of the 10.9.1. installer but i can't seem to make it work. Help please!

    Your friend's installer is tied to his computer, and will require his Apple login id to insall, as well as any future updates.  Since you have Snow Leopard, 10.6.8, use the App Store app and create your own Apple login to download Mavericks from the App Store.  It is free.
    Have a nice day.

Maybe you are looking for

  • Error message: User data is not indexed, yet. Index user data first

    Greeting All, Each time I try to index a 'Prepared' searchObjectConnector in the cockpit.. I get a message < User data is not indexed, yet. Index user data first>. even that I ran the z_ESH_AU_UPLOAD_AUTH_RFC_720 report in R/3 system.. and checked th

  • Dates appear different in log file vs. debug page for Deferred Task

    I added a deferred task and in the log file, the date appeared correctly as Mon Dec 15 16:34:11 PST 2008 But when I viewed the user in the debug page, the date appeared as <Date>2008-12-16T00:34:11.430Z</Date> I called an external java class that ret

  • Disc freezes when played

    I am a new IMac user and really enjoying IMovie. However am having endless problems with IDvd. The burn process appears to work perfectly,but when the disc is played back it freezes at approx 3-4 minutes, eventually quitting with message error readin

  • Half of my video wont work on imovie on ipad mini

    Hi all, i make youtube videos, for christmas i was lucky enough to recieve an ipad mini. i downloaded imovie on it to edit my videos, and i got it for free. i recorded my video on my camera as normal and imported the video on to my laptop (not a mac)

  • Soft Edged Mask tool or plugin?

    Hi there, if I got this right, there is still no way in CS5 Premiere Pro to do a simple soft edged mask like in AE. Is there tool or plugin known for Premiere Pro that could do this at least allows cropping an image and soften the new edges? Thanks!