Re: sp_password

From: Dan Guzman (danguzman_at_nospam-earthlink.net)
Date: 06/20/03


Date: Fri, 20 Jun 2003 07:59:49 -0500


Your locally defined variables included in the xp_cmdshell string are
out of scope when OSQL is executed. Try:

DECLARE @OsqlCommand nvarchar(4000)

SET @OsqlCommand = N'osql -U ldp -P newldp -b ' +
    N'-q "exec sp_password NULL, @new = ''' +
    @NewPassword +
    N''', @loginame = ''' + @loginname + N''''

EXEC master.dbo.xp_cmdshell @OsqlCommand

-- 
Hope this helps.
Dan Guzman
SQL Server MVP
-----------------------
SQL FAQ links (courtesy  Neil Pike):
http://www.ntfaq.com/Articles/Index.cfm?DepartmentID=800
http://www.sqlserverfaq.com
http://www.mssqlserver.com/faq
-----------------------
"Leon Parker" <anonymous@devdex.com> wrote in message
news:e3LeBaoNDHA.3976@tk2msftngp13.phx.gbl...
> Here is a copy of my script where I'm passing in parameter names.
> Whenever I execute the procedure I get the error message that the
login
> '@login' does not exist.  Apparently my parameter is not being passed
in
> correctly.  Can anyone help with the syntax here?
>
> IF @cnt >= 2
> Begin
>
> select @loginname = (select top 1 i.loginname from inserted i)
>
> set @msgtxt = 'SQL username account has been locked out: ' +@loginname
>
> exec master.dbo.xp_sendmail @recipients ='lparker.com',
> @message =    @msgtxt,
> @subject = 'Login Access Violation'
>
> select @NewPassword = 'Lockout' + datename(ms,getdate())
>
> EXEC master.dbo.xp_cmdshell 'osql -U ldp -P newldp -b -q "exec
> sp_password NULL, @new = ''@NewPassword'', @loginame = ''@loginname''
"
> '
>
>
> End
>
>
>
>
>
>
>
> Leon Parker
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!


Relevant Pages

  • Re: reconfigure with overrides
    ... Tibor Karaszi, SQL Server MVP ... When I execute a «reconfigure» statement, I get a 5808 error message. ...
    (microsoft.public.sqlserver.server)
  • Re: Can error messages in Query Analyzer be suppressed?
    ... You can't suppress this. ... But you can execute your drop statement ... SQL Server MVP ...
    (microsoft.public.sqlserver.programming)
  • Re: blue screen
    ... Enquire, plan and execute ... Background information on Stop Error message ...
    (microsoft.public.windowsxp.general)
  • Re: Removing and event from the html code.
    ... Like I said earlier I inherited this script with the page. ... Actually I don't get an error message, ... > This assigns the *result* of running countdown to window.onload. ... window.onload won't execute until the page has fully loaded. ...
    (comp.lang.javascript)
  • Re: LaTeX2rtf not running
    ... Cannot execute C:\PROGRA~1\LATEX2RTF\LATEX2RT.EXE ... Please cite exactly the complete error message ... probably related to window, not to latex2rtf. ...
    (comp.text.tex)