February 14, 2009 at 1:23 pm
Hi,
I'm trying to write this script that backup and restore a test sql login.
first script backup my test login
select sid,dbname,password,language,loginname
into mylogintest
from sys.syslogins where loginname = 'test'
then i delete this test login and try to restore it with this syntax
declare @password sysname
declare @sid varbinary (85)
declare @restorelogin nvarchar (1000)
set @password = (select password from mylogintest)
set @sid = (select sid from mylogintest)
set @restorelogin = 'CREATE LOGIN [test] WITH PASSWORD=''' + @password + ''' HASHED,SID =' + @sid + ', DEFAULT_DATABASE=[system], DEFAULT_LANGUAGE=[us_english], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF'
exec (@restorelogin)
and i get this error message
The data types nvarchar and varbinary are incompatible in the add operator.
why is that?
THX
February 14, 2009 at 3:25 pm
you are trying to insert a varbinary value into a dynamic sql string.
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs" 😉
February 15, 2009 at 12:35 am
so what are my options to resolve this error?
THX
February 15, 2009 at 12:37 pm
Here is some code from Microsoft to transfer logins and passwords from one server to the other.
http://support.microsoft.com/kb/918992
Kind regards,
Gift Peddie
February 16, 2009 at 9:30 am
I agree with the previous post that pointed you to the following link:
http://support.microsoft.com/kb/918992
You can use sp_help_revlogin to script your logins to a file, and have this output backed up with the rest of your DR necessary files (backups, encryption keys, build documenation, ...).
February 16, 2009 at 11:36 am
hi,
i cannot casting it.
i found the answer to it.
i use the master.dbo.fn_varbintohexstr and it's works good.
THX
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply