sql server里将十六进制转换成十进制
在网上找了很多,总是不知道怎么用,于是自己写了一个:
declare @strHex char(5),
@len int,
@intOut int,
@i int,
@charint int
set @strHex = '20'
set @len = len(rtrim(@strHex))
set @i = 1
set @intOut = 0
while @i <= @len
begin
set @charint = case substring(upper(rtrim(ltrim(@strHex))),@i,1)
when 'A' then 10
when 'B' then 11
when 'C' then 12
when 'D' then 13
when 'E' then 14
when 'F' then 15
else substring(@strHex,@i,1)
end
set @intOut = @intOut +@charint * power(16, @len-@i)
set @i = @i + 1
end
print @intOut
由于要批量修改,帮写成了游标的形式:
use pubs
declare @strHex char(5),
@len int,
@intOut int,
@i int,
@charint int,
@keyname char(50)
declare hextoint cursor for
select rtrim(col001),rtrim(col002) from vv
open hextoint
fetch next from hextoint into @keyname,@strHex
while @@fetch_status =0
begin
set @len = len(rtrim(@strHex))
set @i = 1
set @intOut = 0
while @i <= @len
begin
set @charint = case substring(upper(rtrim(ltrim(@strHex))),@i,1)
when 'A' then 10
when 'B' then 11
when 'C' then 12
when 'D' then 13
when 'E' then 14
when 'F' then 15
else substring(@strHex,@i,1)
end
set @intOut = @intOut +@charint * power(16, @len-@i)
set @i = @i + 1
end
update vv set col002 = @intout where col001 = rtrim(@keyname)
--print @intOut
fetch next from hextoint into @keyname,@strHex
end
close hextoint
deallocate hextoint
记以下留作以后参考吧。
相关文档:
<!--
/* Font Definitions */
@font-face
{font-family:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:宋体;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"Cambria Mat ......
1. select top pageSize
* from table where id not in(select top((pageNo-1)*pageSize
) id from table order by id asc)
2. select * from table where id<=pageSize*pageNo
and id>(pageNo-1)*pageSize
order by id asc
注:
pagesize每页显示的记录数
pageNo当前第几页
......
begin
for item in (select * from user_constraints a where a.constraint_type = 'R') loop
execute immediate 'alter table ' || item.table_name || ' disable constraint ' || item.constraint_name;
end loop;
end;
/ ......
1.Stop 所有服务
2.用 Windows Install Clean Up 工具卸载SQL 2005组件
3.用SrvInstw.exe删除所有SQL服务
4.清除注册表
a. 将HKEY_CURRENT_USER---Software----Microsoft下的Microsoft SQL Server文件夹全部删除
b. 将HKEY_LOCAL_mACHINE---SOFTWARE---Microsoft下 ......
一直以来对于SQL的查询都没怎么在意,今天遇到一个关于左连接查询的问题。
Select uId ,uName,dpName
from users
left join dpart
on users.pid=1 where u.pid=dpart.pid
结果是把users所有结果查询出来,而不是pid为1的用户
原来on后面必须放连接条件,其他的条件放在where里面
感谢夏欢提出 ......