JS取屏幕信息
作者:nz.perfectaction 日期:2008-08-04
JavaScript代码
- <script language="javascript">
- function screenInfo(){
- var s = "";
- s += "\r\n网页可见区域宽:"+ document.body.clientWidth;
- s += "\r\n网页可见区域高:"+ document.body.clientHeight;
- s += "\r\n网页可见区域宽:"+ document.body.offsetWidth +" (包括边线的宽)";
- s += "\r\n网页可见区域高:"+ document.body.offsetHeight +" (包括边线的宽)";
- s += "\r\n网页正文全文宽:"+ document.body.scrollWidth;
- s += "\r\n网页正文全文高:"+ document.body.scrollHeight;
- s += "\r\n网页被卷去的高:"+ document.body.scrollTop;
- s += "\r\n网页被卷去的左:"+ document.body.scrollLeft;
- s += "\r\n网页正文部分上:"+ window.screenTop;
- s += "\r\n网页正文部分左:"+ window.screenLeft;
- s += "\r\n屏幕分辨率的高:"+ window.screen.height;
- s += "\r\n屏幕分辨率的宽:"+ window.screen.width;
- s += "\r\n屏幕可用工作区高度:"+ window.screen.availHeight;
- s += "\r\n屏幕可用工作区宽度:"+ window.screen.availWidth;
- alert(s);
- }
- screenInfo();
- </script>
- 注:我试过,如果在网页的前面有如下的W3C标准的头,上面的document.body.clientHeight和document.body.scrollTop是无效的
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
行列互转总结
作者:nz.perfectaction 日期:2008-08-01
SQL代码
- --行列互转
- /******************************************************************************************************************************************************
- 以学生成绩为例子,比较形象易懂
- 整理人:中国风(Roy)
- 日期:2008.06.06
- ******************************************************************************************************************************************************/
- --1、行互列
- --> --> (Roy)生成測試數據
- if not object_id('Class') is null
- drop table Class
- Go
- Create table Class([Student] nvarchar(2),[Course] nvarchar(2),[Score] int)
- Insert Class
- select N'张三',N'语文',78 union all
- select N'张三',N'数学',87 union all
- select N'张三',N'英语',82 union all
- select N'张三',N'物理',90 union all
- select N'李四',N'语文',65 union all
- select N'李四',N'数学',77 union all
- select N'李四',N'英语',65 union all
- select N'李四',N'物理',85
- Go
- --2000方法:
- 动态:
- declare @s nvarchar(4000)
- set @s=''
- Select @s=@s+','+quotename([Course])+'=max(case when [Course]='+quotename([Course],'''')+' then [Score] else 0 end)'
- from Class group by[Course]
- exec('select [Student]'+@s+' from Class group by [Student]')
- 生成静态:
- select
- [Student],
- [数学]=max(case when [Course]='数学' then [Score] else 0 end),
- [物理]=max(case when [Course]='物理' then [Score] else 0 end),
- [英语]=max(case when [Course]='英语' then [Score] else 0 end),
- [语文]=max(case when [Course]='语文' then [Score] else 0 end)
- from
- Class
- group by [Student]
- GO
- 动态:
- declare @s nvarchar(4000)
- Select @s=isnull(@s+',','')+quotename([Course]) from Class group by[Course]
- exec('select * from Class pivot (max([Score]) for [Course] in('+@s+'))b')
- 生成静态:
- select *
- from
- Class
- pivot
- (max([Score]) for [Course] in([数学],[物理],[英语],[语文]))b
- 生成格式:
- /*
- Student 数学 物理 英语 语文
- ------- ----------- ----------- ----------- -----------
- 李四 77 85 65 65
- 张三 87 90 82 78
- (2 行受影响)
- */
- ------------------------------------------------------------------------------------------
- go
- --加上总成绩(学科平均分)
- --2000方法:
- 动态:
- declare @s nvarchar(4000)
- set @s=''
- Select @s=@s+','+quotename([Course])+'=max(case when [Course]='+quotename([Course],'''')+' then [Score] else 0 end)'
- from Class group by[Course]
- exec('select [Student]'+@s+',[总成绩]=sum([Score]) from Class group by [Student]')--加多一列(学科平均分用avg([Score]))
- 生成动态:
- select
- [Student],
- [数学]=max(case when [Course]='数学' then [Score] else 0 end),
- [物理]=max(case when [Course]='物理' then [Score] else 0 end),
- [英语]=max(case when [Course]='英语' then [Score] else 0 end),
- [语文]=max(case when [Course]='语文' then [Score] else 0 end),
- [总成绩]=sum([Score]) --加多一列(学科平均分用avg([Score]))
- from
- Class
- group by [Student]
- go
- --2005方法:
- 动态:
- declare @s nvarchar(4000)
- Select @s=isnull(@s+',','')+quotename([Course]) from Class group by[Course] --isnull(@s+',','') 去掉字符串@s中第一个逗号
- exec('select [Student],'+@s+',[总成绩] from (select *,[总成绩]=sum([Score])over(partition by [Student]) from Class) a
- pivot (max([Score]) for [Course] in('+@s+'))b ')
- 生成静态:
- select
- [Student],[数学],[物理],[英语],[语文],[总成绩]
- from
- (select *,[总成绩]=sum([Score])over(partition by [Student]) from Class) a --平均分时用avg([Score])
- pivot
- (max([Score]) for [Course] in([数学],[物理],[英语],[语文]))b
- 生成格式:
- /*
- Student 数学 物理 英语 语文 总成绩
- ------- ----------- ----------- ----------- ----------- -----------
- 李四 77 85 65 65 292
- 张三 87 90 82 78 337
- (2 行受影响)
- */
- go
- --2、列转行
- --> --> (Roy)生成測試數據
- if not object_id('Class') is null
- drop table Class
- Go
- Create table Class([Student] nvarchar(2),[数学] int,[物理] int,[英语] int,[语文] int)
- Insert Class
- select N'李四',77,85,65,65 union all
- select N'张三',87,90,82,78
- Go
- --2000:
- 动态:
- declare @s nvarchar(4000)
- select @s=isnull(@s+' union all ','')+'select [Student],[Course]='+quotename(Name,'''')--isnull(@s+' union all ','') 去掉字符串@s中第一个union all
- +',[Score]='+quotename(Name)+' from Class'
- from syscolumns where ID=object_id('Class') and Name not in('Student')--排除不转换的列
- order by Colid
- exec('select * from ('+@s+')t order by [Student],[Course]')--增加一个排序
- 生成静态:
- select *
- from (select [Student],[Course]='数学',[Score]=[数学] from Class union all
- select [Student],[Course]='物理',[Score]=[物理] from Class union all
- select [Student],[Course]='英语',[Score]=[英语] from Class union all
- select [Student],[Course]='语文',[Score]=[语文] from Class)t
- order by [Student],[Course]
- go
- --2005:
- 动态:
- declare @s nvarchar(4000)
- select @s=isnull(@s+',','')+quotename(Name)
- from syscolumns where ID=object_id('Class') and Name not in('Student')
- order by Colid
- exec('select Student,[Course],[Score] from Class unpivot ([Score] for [Course] in('+@s+'))b')
- go
- select
- Student,[Course],[Score]
- from
- Class
- unpivot
- ([Score] for [Course] in([数学],[物理],[英语],[语文]))b
- 生成格式:
- /*
- Student Course Score
- ------- ------- -----------
- 李四 数学 77
- 李四 物理 85
- 李四 英语 65
- 李四 语文 65
- 张三 数学 87
- 张三 物理 90
- 张三 英语 82
- 张三 语文 78
- (8 行受影响)
- */
Tags: 行转列
set lock_timeout 控制sql超时
作者:nz.perfectaction 日期:2008-07-31
sql 2005的begin try 和 begin catch 配合set lock_timeout,可以实现控制sql超时,例:
set lock_timeout 5000
declare @i int
declare @T table(data varchar(30))
set @i =0;
while ( @i < 100)
begin
begin try
insert @T select aa from tb where aa=1
&...
set lock_timeout 5000
declare @i int
declare @T table(data varchar(30))
set @i =0;
while ( @i < 100)
begin
begin try
insert @T select aa from tb where aa=1
&...
关于"按某列分组,求最新一条记录"两种sql写法的测试
作者:nz.perfectaction 日期:2008-07-29
-----------------------------------------------------------------------
--组织测试数据,首先我们来组织category分类比较少的情况,分了体现这个差别,所以只分了两个分类
drop table tb
create table tb(id int identity primary key,category nvarchar(50),remark char(5000))
declare @i int set @i=1
while @i<=5000
&nb...
--组织测试数据,首先我们来组织category分类比较少的情况,分了体现这个差别,所以只分了两个分类
drop table tb
create table tb(id int identity primary key,category nvarchar(50),remark char(5000))
declare @i int set @i=1
while @i<=5000
&nb...
Tags: sql优化
发现有pr值了,我的是3
作者:nz.perfectaction 日期:2008-07-29
SQL [转]Server 2000下将数据库直接备份到网络上其它计算机硬盘
作者:nz.perfectaction 日期:2008-07-28
SQL Server 2000下将数据库直接备份到网络上其它计算机硬盘:
具体方法如下:
1.两台机器(数据库所在的机器和存放备份文件的机器)都需要建一个同名同密码的用户,方便起见,最好将这两个用户都直接归到管理员组下;
2.将数据库的启动帐户设置成刚才所建立的那个帐户,并重新开启SQL服务;
3.假设远程机器的IP是192.168.61.234,共享为默认共享f$,先用查询分析器登陆到本地的SQL服务器(用sa和信任模式都可以),在master下执行xp_cmdshell 'dir \\192.168.61.234\f$'看有没有结果,还是有报错的,如有报错,请根据错误提示检查;
4.执行以下备份语句可将数据库备份到远程硬盘上,以crm2k为例:
backup database crm2k to disk='\\192.168.61.234\f$\crm2k0722_2.dmp'
5.同时注意,一定要用“\\机器名或IP”不能用映射的盘符。查看更多...
具体方法如下:
1.两台机器(数据库所在的机器和存放备份文件的机器)都需要建一个同名同密码的用户,方便起见,最好将这两个用户都直接归到管理员组下;
2.将数据库的启动帐户设置成刚才所建立的那个帐户,并重新开启SQL服务;
3.假设远程机器的IP是192.168.61.234,共享为默认共享f$,先用查询分析器登陆到本地的SQL服务器(用sa和信任模式都可以),在master下执行xp_cmdshell 'dir \\192.168.61.234\f$'看有没有结果,还是有报错的,如有报错,请根据错误提示检查;
4.执行以下备份语句可将数据库备份到远程硬盘上,以crm2k为例:
backup database crm2k to disk='\\192.168.61.234\f$\crm2k0722_2.dmp'
5.同时注意,一定要用“\\机器名或IP”不能用映射的盘符。
修复一个表
作者:nz.perfectaction 日期:2008-07-24
alter database 库名 set single_user
--dbcc checktable('表名',repair_rebuild)
dbcc checktable('表名',repair_allow_data_loss)
alter database 库名 set multi_user
--dbcc checktable('表名',repair_rebuild)
dbcc checktable('表名',repair_allow_data_loss)
alter database 库名 set multi_user
查询一个字符串位于哪个表
作者:nz.perfectaction 日期:2008-07-23
declare @searchstr nvarchar(500)
set @searchstr ='Publisher' --这里是你要查的字符内容
declare @t varchar(255),@c varchar(255)
create table # (name varchar(256),cols varchar(4000))
declare table_cursor cursor for
select a.name,b.name from sysobjects a,syscolumns &...
set @searchstr ='Publisher' --这里是你要查的字符内容
declare @t varchar(255),@c varchar(255)
create table # (name varchar(256),cols varchar(4000))
declare table_cursor cursor for
select a.name,b.name from sysobjects a,syscolumns &...






