下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。
内存溢出小编现在分享给大家,也给大家做个参考。
-- copyright (C) 1991-2002 sqlDev.Net-- -- file: sp_sqlagent_set_connection.sql-- descr.: Set login and password for regular connections to sql Agent-- author: Gert E.R. Drapers (@L_301_0@)---- @@bof_revsion_marker-- revision history-- yyyy/mm/dd by description-- ========== ======= ==========================================================-- 2003/03/20 gertd v1.0.0.0 first release-- -- @@eof_revsion_marker-- ***************************************************************************use msdbgo if exists (select * from sysobjects where name = 'sp_sqlagent_set_connection' and type = 'P') drop proc dbo.sp_sqlagent_set_connectiongocreate proc dbo.sp_sqlagent_set_connection @host_login_name sysname,@host_login_password sysname,@regular_connections int = NulLas set nocount on declare @rc int,@os int -- check if sysadmin role member if is_srvrolemember ('sysadmin') <> 1 begin raiserror('Only members of the sysadmin role can execute sp_sqlagent_set_connection',16,1) return end -- check parameters if (@host_login_name is null) or (len(@host_login_name) = 0) begin raiserror('Illegal parameter value %s is NulL or empty',1,'@host_login_name') return end if (@host_login_password is null) or (len(@host_login_password) = 0) begin raiserror('Illegal parameter value %s is NulL or empty','@host_login_password') return end -- check if sql Server 2000,depends on master.dbo.xp_sqlagent_param if (charindex(N'8.00',@@version,0) = 0) begin raiserror('sp_sqlagent_set_connection is not supported for versions earlIEr than sql Server 2000',18,1) return end -- check OS,master.dbo.xp_sqlagent_param only works on NT exec @rc = master.dbo.xp_MSplatform @os output if (@os = 2) -- windows 9x begin raiserror('sp_sqlagent_set_connection is not supported on windows 95/98 platforms',1) return end -- only if @regular_connections is turned on we allow setting the connection,otherwise we delete it if (@regular_connections is null) begin exec @rc = master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE',N'SOFTWARE\Microsoft\MSsqlServer\sqlServerAgent',N'RegularConnections',@regular_connections OUTPUT,N'no_output' end else begin exec @rc = master.dbo.xp_instance_regwrite N'HKEY_LOCAL_MACHINE',N'REG_DWORD',@regular_connections end -- delete user ID and password if (@regular_connections = 0) begin print N'Delete HostLoginID' exec @rc = master.dbo.xp_sqlagent_param 2,N'HostLoginID' print N'Delete HostPassword' exec @rc = master.dbo.xp_sqlagent_param 2,N'HostPassword' end -- set user ID and password if (@regular_connections = 1) begin print N'Set HostLoginID' exec @rc = master.dbo.xp_sqlagent_param 1,N'HostLoginID',@host_login_name print N'Set HostPassword' exec @rc = master.dbo.xp_sqlagent_param 3,N'HostPassword',@host_login_password endgo-- sample usage-- regular_connections is already turned on either using sql Enterprise Manager or -- exec msdb.dbo.sp_set_sqlagent_propertIEs @regular_connections = 1-- this sets the login and passwordexec msdb.dbo.sp_sqlagent_set_connection N'sa',N'LowRIDer99'-- this switches to regular connections and set the login and passwordexec msdb.dbo.sp_sqlagent_set_connection N'sa',N'LowRIDer99',1
以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
总结以上是内存溢出为你收集整理的设置SQL的Agent代理的登陆名和密码问题全部内容,希望文章能够帮你解决设置SQL的Agent代理的登陆名和密码问题所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)