sql 加密
use Tempdb
go
if object_ID ( 'fn_ACITEncryption' ) is not null
drop function fn_ACITEncryption
go
create function fn_ACITEncryption
(
@Str nvarchar ( 4000), -- 加密的字符串
@Flag bit = 1, --1 、加密 0 、解密
@Key nvarchar ( 50) -- 密文
)
returns nvarchar ( 4000) -- 這里可轉換成二進制
with Encryption
as
begin
Declare @LenStr int , @i int , @Str2 nvarchar ( 4000), @Split nvarchar ( 2), @LenKey int
select @Str= @Str+ 'A' , @LenStr= len ( @Str), @i= 1, @Str2= '' , @LenKey= Len ( @Key+ 'A' )- 1
while @i< @LenStr
select @Split= substring ( @Str, @i, 1),
@Split= nchar (( unicode ( @Split)+ case @Flag when 1 then unicode ( substring ( @Key+ 'A' , @i% @LenKey+ 1, 1))- 1
when 0 then 65535- unicode ( substring ( @Key+ 'A' , @i% @LenKey+ 1, 1))
else 0 end )% 65535+ cast ( @Flag as int )),
@Str2= @Str2+ @Split, @i= @i+ 1
return @Str2
end
go
select dbo. fn_ACITEncryption( N'Roy' , 1, '123' ) as 加密后字符串
/*
加密后字符串
------------------------------
(1 個資料列受到影響 )
*/
select dbo. fn_ACITEncryption( N, 0, '123' ) as 解密后字符串
/*
解密后字符串
--------------------------
Roy
(1 個資料列受到影響 )
*/
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/roy_88/archive/2009/11/12/4801917.aspx
相关文档:
系统环境:Windows 7
软件环境:Visual C++ 2008 SP1 +SQL Server 2005
本次目的:编写一个航空管理系统
这是数据库课程设计的成果,虽然成绩不佳,但是作为我用VC++ 以来编写的最大程序还是传到网上,以供参考。用VC++ 做数据库设计并不容易,但也不是不可能。以下是我的程序界面,后面 ......
TA:
1,WANG
2,ZHANG
4,LI
TB:
1,100
2,200
3,400
1.left join 左连接--以左表为基准,右表中没值的,在结果集中以null值代替。(select * from TA left join TB where TA.ID=TB.ID)
1,WANG,100
2,ZHANG,200
4,NULL
2.right join 右连接--以右表为基准,左表中没值的,在 ......
string str = System.Configuration.ConfigurationManager.AppSettings["strconn"];
string sqlpwd = "select password from bg_user where username='" + username + "'";
MySqlConnection conn = new MySqlConnection(str);
MySqlCommand cmd=new MySqlCommand(sqlpwd,conn);
MySqlDataAdapter adr = new MySqlDataA ......
SQL server安装时报挂起错误
SQL server安装时时:“以前的某个程序安装已在安装计算机上创建挂起的文件操作。运行安装程序之前必须重新启动计算机”错误。 打开注册表编辑器(开始->运行->regedit),在HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager中找到PendingFileRenameOperations项目,并删 ......
常用SQL查询:
1、查看表空间的名称及大小
select t.tablespace_name, round(sum(bytes/(1024*1024)),0) ts_size
from dba_tablespaces t, dba_data_files d
where t.tablespace_name = d.tablespace_name
group by t.tablespace_name;
2、查看表空间物理文件的名称及大小
select tablespace_name, file_id, ......