Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 xp_repl_encrypt

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-04-25 : 12:19:34
Martin writes "In SQL 7.0 I use code, which doesn't work in SQL 2000.

In registry I have encrypted password (with xp_repl_encrypt, seems to work correct in both versions) and I want to read it from registry and decrypt (work only on SQL 7.0). Can you help me?

declare @password sysname, @pwd_bin varbinary(256), @ret_code int, @stat_ok bit
select @stat_ok = 1

execute @ret_code = master.dbo.xp_regread
'HKEY_LOCAL_MACHINE',
'SOFTWARE\Microsoft\MSSQLServer\MSSQLServer',
'myapp_password', @param = @pwd_bin OUTPUT
if @ret_code <> 0 or @@error <> 0
select @stat_ok = 0

if @stat_ok = 1
begin
select @password = convert(sysname, @pwd_bin)
execute master.dbo.xp_repl_encrypt @password OUTPUT

if @ret_code <> 0 or @@error <> 0
select @stat_ok = 0
end

select @stat_ok status, @password password "
   

- Advertisement -