董川民 发布的文章

SQL语句查询某个数据库中某类表或视图

数据库:Sqlserver
SQL语句:

select * from sysobjects where name like 'Sys%' and (xtype = 'U' or xtype = 'V') order by name

如果筛选的表名称中,包含有下划线_,则用下面语句:

select * from sysobjects where name like 'Sys/_%' ESCAPE '/' and (xtype = 'U' or xtype = 'V') order by name

在Sqlserver的like中下划线类似于通配符%,所以无法使用like '%_%'来匹配下划线,使用转义字符escape。

在语句中,当转义符置于通配符之前时,该通配符就解释为普通字符。上面第二个SQL语句中,‘/’为转义字符,第一、第三个‘%’为通配符。

阅读剩余部分

SQL语句查询某表中所有字段的名称、类型、长度等属性信息

数据库:Sqlserver
SQL语句:

SELECT  
字段名=a.name,
标识=case when COLUMNPROPERTY(a.id,a.name,'IsIdentity')=1 then '√'else '' end,
主键=case when exists(SELECT 1 FROM sysobjects where xtype='PK' and name in (SELECT name FROM sysindexes WHERE indid in(SELECT indid FROM sysindexkeys WHERE id = a.id AND colid=a.colid))) then '√' else '' end,
类型=b.name,
占用字节数=a.length,
长度=COLUMNPROPERTY(a.id,a.name,'PRECISION'),
小数位数=isnull(COLUMNPROPERTY(a.id,a.name,'Scale'),0),
允许空=case when a.isnullable=1 then '√'else '' end,
默认值=isnull(e.text,''),
字段说明=isnull(g.[value],'')
FROM syscolumns a
left join systypes b on a.xtype=b.xusertype 
inner join sysobjects d on a.id=d.id and d.xtype='U' and d.name<>'dtproperties' 
left join syscomments e on a.cdefault=e.id 
left join sys.extended_properties g on a.id=g.major_id and a.colid=g.minor_id 
left join sys.extended_properties f on d.id=f.major_id and f.minor_id =0 
Where d.name='Table_Name'
Order by a.name

阅读剩余部分

window.onload与$(document).ready()差异对比

一,执行时机
window.onload():在页面所有元素(包括图片,引用文件)加载完后执行。
$(document).ready():页面中所有HTML DOM,CSS DOM结构加载完之后就会执行,其他图片文件可能没有加载完。

二,编写个数
window.onload(): 不能同时写多个,后面的将会覆盖前面的。

window.onload=function(){ 
    alert("A"); 
}
window.onload=function(){ 
    alert("B"); 
}

结果会执行“B”,如果想要顺序执行alert("A")和alert("B")需写成:

window.onload=function(){
    alert("A");
    alert("B");
}

$(document).ready(): 可以同时写多个,以下代码正确执行。

$(document).ready(function (){
   alert("Hello World!"); 
});
$(document).ready(function (){
   alert("Helllo World!"); 
});

三,简写方法
window.onload(): 无简写,但有相关写法。

$(window).load(function () {
});
// 等价于
window.onload = function () {
};

$(document).ready(): 有简写

$(document).ready(function(){
  //to do;
});

可写成

$().ready(function(){   //$()不带参数默认是document
  //to do;
});

$(function(){
  //to do;
});

阅读剩余部分

js插件Autosize实现textarea标签高度自适应,且取消右边滚动条

Autosize插件官方:https://github.com/jackmoore/autosize
案例代码:

<!DOCTYPE html>
<html>
	<head>
		<meta charset='utf-8' />
		<title>Simple Autosize for textareas</title>
		<style>
			textarea {
                padding: 10px; 
                vertical-align: top; 
                width: 200px; 
                resize:none;
                outline:none; 
            }
           textarea:focus { 
                outline-style: solid; 
                outline-width: 2px;
			}
		</style>
	</head>
	<body>
		<h3>max-height 300px</h3>
		<textarea style='max-height: 300px'>
			The coconut palm (also, cocoanut), Cocos nucifera, is a member of the
			family Arecaceae (palm family). It is the only accepted species in the
			genus Cocos.[2] The term coconut can refer to the entire coconut palm,
			the seed, or the fruit, which, botanically, is a drupe, not a nut. The
			spelling cocoanut is an archaic form of the word.[3] The term is derived
			from 16th-century Portuguese and Spanish coco, meaning "head" or "skull",[4]
			from the three small holes on the coconut shell that resemble human facial
			features.
		</textarea>
		<h3>no max-height</h3>
		<textarea>
			The coconut palm (also, cocoanut), Cocos nucifera, is a member of the
			family Arecaceae (palm family). It is the only accepted species in the
			genus Cocos.[2] The term coconut can refer to the entire coconut palm,
			the seed, or the fruit, which, botanically, is a drupe, not a nut. The
			spelling cocoanut is an archaic form of the word.[3] The term is derived
			from 16th-century Portuguese and Spanish coco, meaning "head" or "skull",[4]
			from the three small holes on the coconut shell that resemble human facial
			features.
		</textarea>
	</body>
	<script src='/autosize.min.js'></script>
	<script>
		autosize(document.querySelectorAll('textarea'));
	</script>
</html>

阅读剩余部分

web.config配置文件中特殊字符的处理

在安装一个ASP.NET网站时,遇到问题,首先打开网站首页时,报错如下:
配置文件的XML格式不正确.png
然后在IIS里随便点击其他配置,比如默认文档,也会弹错:
web.config配置xml格式不正确.png
仔细看错误提示,发现sqlserver的数据库配置那一行标红了,然后反复试账号和密码的对错,没有解决问题。然后再网上看到我现在红框标注的地方:配置文件的XML格式不正确,这才是关键。

阅读剩余部分