Sqlserver UrlEncode
程序员文章站
2022-10-04 23:43:12
Sqlserver UrlEncode ......
sqlserver urlencode
if exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[urlencode]') and xtype in (n'fn', n'if', n'tf'))
-- 删除函数
drop function [dbo].[urlencode]
go
create function dbo.urlencode(@url varchar(3072))
returns varchar(3072)
as
begin
declare @count int,
@char varchar(2),
@i int,
@bytes binary(2),
@low8 int,
@high8 int
declare @urlencode varchar(3000) ;
set @count = len(@url)
set @i = 1
set @urlencode = ''
while (@i <= @count)
begin
set @char = substring(@url,@i,1)
if @char like '[-a-za-z0-9()''*._!]' and datalength(@char) = 1
set @urlencode = @urlencode + @char
else
begin
if datalength(@char) = 1
begin
set @urlencode = @urlencode + '%' + substring('0123456789abcdef',(ascii(@char) / 16 + 1),1)
set @urlencode = @urlencode + substring('0123456789abcdef',(ascii(@char) % 16 + 1),1)
end
else
begin
set @bytes = convert(binary,@char)
set @high8 = (0xff00 & cast(@bytes as int))/256
set @low8 = 0x00ff & cast(@bytes as int)
set @urlencode = @urlencode + '%' + substring('0123456789abcdef',(@high8 / 16 + 1),1)
set @urlencode = @urlencode + substring('0123456789abcdef',(@high8 % 16 + 1),1)
set @urlencode = @urlencode + '%' + substring('0123456789abcdef',(@low8 / 16 + 1),1)
set @urlencode = @urlencode + substring('0123456789abcdef',(@low8 % 16 + 1),1)
end
end
set @i = @i + 1
end
return @urlencode;
end
上一篇: 加载并全屏轮播加载的其他网站的页面
下一篇: Python的_文件操作
推荐阅读
-
学习SQLSERVER2005高可用性数据库镜像的一些心得
-
sqlServer 数据库常用连接字符串
-
SQLSERVER Pager store procedure分页存储过程
-
mssql sqlserver 使用sql脚本输出交替不同的背景色的html信息的方法分享
-
小觑数据库(SqlServer)查询语句执行过程
-
mssql sqlserver 获取指定日期为本月第几个工作日
-
SQLServer 2008 新增T-SQL 简写语法
-
SQLServer 2008中SQL增强之二 Top新用途
-
还原sqlserver2008 媒体的簇的结构不正确的解决方法
-
SQLserver日期格式问题(转)