sql-server - Delphi ORD、SHL 和 SHR 函数 SQL Server 的等效项是什么?
问题描述
我有 2 个 Delphi 函数需要迁移到 SQL Server,但我不确定 ORD、SHL 和 SHR 函数的等效项。有人可以帮助了解这些 Delphi 函数在 SQL 中的样子吗?
function QX_Encrypt(s:String) : String;
var
sTempString : string;
iIndex , i: integer;
begin
sTempString := s ;
for iIndex := 1 to length(sTempString) do
begin
i := ord(sTempString[iIndex]);
i:= i shl 1;
sTempString[iIndex] := char(i) ;
end;
result := stempstring;
end;
function QX_Decrypt(s:String) : String;
var
sTempString : string;
iIndex , i : integer;
begin
sTempString := s ;
for iIndex := 1 to length(sTempString) do
begin
i := ord(sTempString[iIndex]);
i:= i shr 1;
sTempString[iIndex] := char(i) ;
end;
result := sTempString;
end;
解决方案
感谢您的指导。这是一个片段,它做了我想要的。
DECLARE
@cnt INT = 1,
@Password nvarchar(20) = 'P@ssword1',
@NewPassword nvarchar(20)
WHILE @cnt < LEN(@Password) + 1
BEGIN
SELECT @NewPassword = CONCAT(@NewPassword, CHAR(ASCII(SUBSTRING(@Password, @cnt, 1)) * 2))
SET @cnt = @cnt + 1;
END;
SELECT @NewPassword
推荐阅读
- c++ - 在 NVIDIA 和 Intel GPU 上启动内核时的 OpenCL CL_INVALID_COMMAND_QUEUE
- vbscript - 这些 VBScript 语句有什么作用?
- python - "IsADirectoryError: [Errno 21] 是一个目录:" 它是一个文件
- javascript - Onerror 和 onload 事件不会在反应的脚本元素中触发
- amazon-web-services - AWS EMR 与 Glue 目录,明确指定 catalogId
- google-bigquery - 我想在插入 Bigquery 表时生成唯一 ID。
- mysql - 获取 MySQL 中受影响的行数
- lda - 如何用槌预测一批文档的主题
- sql-server - 在数据库表中创建多个地址
- amazon-web-services - AWS Server Migration Service Hyper-V 连接器运行状况不佳