liufeng

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

//判断是否为字母与数字
^[A-Za-z0-9]+$

//判断移动电话或固定电话(我是大连的,所以区号是0411)
^(?:1[35]\d{9}|0411\d{8})$

//判断年龄
^(1[0-2]\d|\d{1,2})$

//字母数字汉字
^[a-zA-Z0-9\u4e00-\u9fa5]+$

//判断是文件类型
^.+\.(jpe?g|JP?G|Jp?g|GIF|Gif|gif)$

===================================================================

还有一些SQL语句
//查询本周情况
select * from cardInfo
where
datepart(wk,字段名)=datepart(wk,getdate())
and
datepart(yy,字段名)=datepart(yy,getdate())

//随机抽取4个
select top 4 * from tablename order by newid()

//不全显示电话号码
select left(ltrim(字段名),3)+'****'+right(rtrim(字段名),4) from 表名
Select Stuff(字段名, 4, 4, '****') As num From 表名

//数据为1或0,显示出来为是或否
select (case 字段名 when 1 then '是' else '否' end) as isTrade from client

//把字段中的回车替换成空格
select audName,audSex,audAge,audTel,replace(audcontent,char(13)+char(10),''),audEpname as 游戏名称,audTime from audited

//循环插入数据
declare @a bigint
set @a=2008080841100001
while @a<=2008080841199999
begin
insert into card(cardNum)
select @a
set @a=@a+1
end


declare @k bigint
declare @n bigint
set @k=2008080841100001
select @n=max(cardnum) from card
while(@k<2008080841199999)
begin
INSERT INTO [card]
           ([cardnum])
     VALUES
           (@k)
set @k=@k+1
end

循环更新某字段

declare @t table(aaa int,  eee int,  ccc varchar(2),  ddd  int)
insert @t select
1 ,   2    ,'a',    100  union select
2 ,   2    ,'a',    null union select
3 ,   1    ,'c',    null union select
4 ,   2    ,'a',    null union select
5 ,   3    ,'a',    null union select
6 ,   2    ,'b',    null union select
7 ,   2    ,'a',    null union select
8  ,  2    ,'a',    null union select
9  ,  2    ,'a',    null 


declare @i int
set @I = -1

update @t 
set ddd = @i,@i =isnull(ddd,0+ @i +1
where eee = 2 and ccc = 'a'
select * from @t
posted on 2008-01-25 17:05  嚣张的沉默  阅读(281)  评论(0编辑  收藏  举报