易截截图软件、单文件、免安装、纯绿色、仅160KB
热门标签: c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 最新文章 : sql

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 @St ......

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))
......

SQL按照日、周、月、年统计数据

SQL按照日、周、月、年统计数据 收藏
文章参考:http://www.cnblogs.com/wenbhappy/archive/2008/07/02/1233660.html
如: 
表:consume_record 
字段:consume (money类型) 
date (datetime类型) 
请问怎么写四条sql语句分别按日,按周,按月,按季统计消费总量. 
如:1月 1200元 
2月 3400元 
3月 2800元 
--按日 
select sum(consume),day([date]) from consume_record where year([date]) = '2006' group by day([date]) 
--按周quarter 
select sum(consume),datename(week,[date]) from consume_record where year([date]) = '2006' group by datename(week,[date]) 
--按月 
select sum(consume),month([date]) from consume_record where year([date]) = '2006' group by month([date]) 
--按季 
select sum(consume),datename(quarter,[date]) from consume_record  ......

AIR执行SQL语句

 我们的SQL语句的执行都是由一个类来完成的!这个类就是SQLStatement,这个类就是我们用来执行SQL语句的类,该类的使用也是非常简单的,我们只需要记住两个属性两个方法。我们来看一下!
text属性:所要执行的SQL语句,该属性是一个字符串格式,所以我们的SQL语句都是字符串!
sqlConnection属性:该属性是设置SQLStatement对象所要绑定的SQLConnection对象,这个属性我们一般在创建SQLStatment对象的时候就设定的!
execute方法:这个方法很简单,表示执行SQL语句。(有点像play)
getResult方法:这个方法挺重要的,因为我们访问的数据库后返回的数据都通过这个方法存储到一个SQLResult对象中!
    好了!我们来看一个实例吧!这个实例中将执行一个查询语句,该语句查询后的结果会trace出来!
package
{
import flash.data.SQLConnection;
import flash.data.SQLResult;
import flash.data.SQLStatement;
import flash.display.Sprite;
import flash.errors.SQLError;
import flash.events.MouseEvent;
import flash.events.SQLErrorEvent;
import flash.events.SQLEvent;
import flash.filesystem.File;
/**
* ...
* */
public ......

sql中的分段列表

表:用户号码,登录时间
显示 :每日登录各时间段的登录人数,和每天登录人数
if isnull(object_id('#tb'),'')=''
drop table #tb
CREATE TABLE #tb(列名1 varchar(12),时间 datetime)
INSERT INTO #tb
SELECT '03174190188','2009-11-01 07:17:39.217' UNION ALL
SELECT '015224486575','2009-11-01 08:01:17.153' UNION ALL
SELECT '013593006926','2009-11-12 08:04:46.560' UNION ALL
SELECT '013593006926','2009-11-12 07:05:46.560' UNION ALL
SELECT '013599584239','2009-11-22 08:53:27.763' UNION ALL
SELECT '013911693526','2009-11-23 08:53:51.683' UNION ALL
SELECT '013846472440','2009-11-23 08:54:57.233' UNION ALL
SELECT '013990353697','2009-11-24 08:55:25.077' UNION ALL
SELECT '013990353697','2009-11-25 08:56:01.327' UNION ALL
SELECT '013945594843','2009-11-26 08:57:02.233' UNION ALL
SELECT '013990353697','2009-11-27 08:57:29.700' UNION ALL
SELECT '013916597421','2009-11-28 08:59:49.390' UNION ALL
SELECT '03916995857','2009-11-29 09:11:05.607' UNION ALL
SELECT '015097712001','2009-11-30 09:13:5 ......

SQL 每个分类各取2条数据

create table tb (ptoid int,proclassid int,proname varchar(10))
insert tb
select 1,1,'衣服1'
union all
select 2,2,'衣服2'
union all
select 3,3,'衣服3'
union all
select 4,3,'衣服4'
union all
select 5,2,'衣服5'
union all
select 6,2,'衣服6'
union all
select 7,2,'衣服7'
union all
select 8,1,'衣服8'
select * from tb
ptoid       proclassid  proname   
----------- ----------- ----------
1           1           衣服1
2           2           衣服2
3           3           衣服3
4           3           衣服4
5   &nb ......
总记录数:4346; 总页数:725; 每页6 条; 首页 上一页 [430] [431] [432] [433] 434 [435] [436] [437] [438] [439]  下一页 尾页
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号