我正在运行一些 sql,它从临时表中获取信息并将其放入永久表中。我是从 3 年前写的分步指南中得到的,写它的人早已不在。它声明在这里使用这个 sql。
declare @Password nvarchar(100);
set @Password ='rewards';
if not exists(select 1 from sys.openkeys where key_name = 'Sym_UserPassData'
and database_name = db_name()) OPEN SYMMETRIC KEY Sym_UserPassData DECRYPTION BY
CERTIFICATE UserPassTables with password='asbpass71509new';
INSERT INTO [User] (Username, [Password], AllowChange, ForceChange, FullName,
SalesRep, OpenLink, UserProfileID, LastUpdatedBy,UserEmail)
(SELECT Username,EncryptByKey(Key_GUID('Sym_UserPassData'),@Password),
AllowChange, ForceChange, FullName, SalesRep, [OpenLink ], UserProfileID,
LastUpdateBy, UserEmail FROM TempUsers)
然后它说以下
如果每一行的密码都是唯一的,则取 set @Password = 'Password'; 关闭并将@Password 替换为[Password]。
所以起初我只是改变了第二行所以它说
declare @Password nvarchar(100);
set [Password]
...
但这给了我密码列的错误,所以我将其更改为:
declare [Password] nvarchar(100);
set [Password]
if not exists(select 1 from sys.openkeys where key_name = 'Sym_UserPassData'
and database_name = db_name()) OPEN SYMMETRIC KEY Sym_UserPassData DECRYPTION BY
CERTIFICATE UserPassTables with password='asbpass71509new';
INSERT INTO [User] (Username, [Password], AllowChange, ForceChange, FullName,
SalesRep, OpenLink, UserProfileID, LastUpdatedBy,UserEmail)
(SELECT Username,EncryptByKey(Key_GUID('Sym_UserPassData'),[Password]),
AllowChange, ForceChange, FullName, SalesRep, [OpenLink ], UserProfileID,
LastUpdateBy, UserEmail FROM TempUsers)
这就是给我错误的原因:
nvarchar is not a recognized cursor option
有谁知道我错过了什么?如果我能提供任何其他信息,我会尽我所能。
感谢任何能够提供帮助的人。