ms sql server 搜索存儲過程語句中的字符串

refer from: http://yixin416757625.iteye.com/blog/1472899

可以方便的在所有的存儲過程腳本中查找字符串:

USE [test]
GO
/****** 对象:  StoredProcedure [dbo].[search_proc_word]    脚本日期: 08/07/2012 09:32:53 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
– =============================================
– Author:        <Author,,Name>
– Create date: <Create Date,,>
– Description:    <Description,,>
– =============================================
CREATE PROCEDURE [dbo].[search_proc_word]
– Add the parameters for the stored procedure here

@word varchar(100)
AS
BEGIN
– SET NOCOUNT ON added to prevent extra result sets from
– interfering with SELECT statements.
SET NOCOUNT ON;

Declare @proc_name varchar(100)
Declare @fuction_name varchar(100)
Declare @seek_text varchar(100)
set @fuction_name= @word –要查找的字符串

set @seek_text=@fuction_name
Declare @sql varchar(8000)
Create table #proc_count(proc_name varchar(100),fuction_name varchar(100),[text] varchar(7000))
Create table #proc_text([text] varchar(8000))

Declare Cursor_Function cursor
for
select quotename(name) from sys.sysobjects where xtype=’P’

Open Cursor_Function
Fetch next from Cursor_Function into @proc_name

While @@fetch_status=0
Begin
truncate table #proc_text
set @sql=”
set @sql=@sql+’
insert into #proc_text([text])
exec sp_helptext ‘+””+@proc_name+””+’

If exists(select 1 from #proc_text where [Text] like ‘+””+’%’+@seek_text+’%’+””+’)
begin
insert into #proc_count(proc_name,fuction_name,[text])
select ‘+””+@proc_name+””+’,’+””+@fuction_name+””+’,’+’[text]
from #proc_text
where [Text] like ‘+””+’%’+@seek_text+’%’+””+’
end’

print @sql
exec (@sql)

Fetch next from Cursor_Function into @proc_name
end

close Cursor_Function
deallocate Cursor_Function

select distinct proc_name,fuction_name from #proc_count
order by proc_name

drop table #proc_count
drop table #proc_text

END

 

发表在 Program, Windows | 标签为 | 留下评论

delphi StringList date sort

function CompareDates(List: TStringList; Index1, Index2: Integer): Integer;
var
d1, d2: TDateTime;
AFormat, AFormat2: TFormatSettings;
begin
AFormat.DateSeparator := ‘/’;
AFormat.ShortDateFormat := ‘yyyy/mm/dd’;
AFormat2.DateSeparator := ‘-’;
AFormat2.ShortDateFormat := ‘yyyy-mm-dd’;
if Pos(‘/’, LeftStr(List[Index1],10)) > 0 then
d1 := StrToDate(LeftStr(List[Index1],10),AFormat);
if Pos(‘/’, LeftStr(List[Index2],10)) > 0 then
d2 := StrToDate(LeftStr(List[Index2],10),AFormat);
if Pos(‘-’, LeftStr(List[Index1],10)) > 0 then
d1 := StrToDate(LeftStr(List[Index1],10),AFormat2);
if Pos(‘-’, LeftStr(List[Index2],10)) > 0 then
d2 := StrToDate(LeftStr(List[Index2],10),AFormat2);

if d1 < d2 then
Result := -1
else if d1 > d2 then Result := 1
else
Result := 0;
end;

自定義排序:

DateList.CustomSort(CompareDates);

 

ref:

http://www.swissdelphicenter.ch/en/showcode.php?id=1664

http://hi.baidu.com/caihexi/item/e99ab1154df6e70b8fbde425

发表在 Program | 标签为 | 留下评论

簡單的HTML圖片瀏覽功能

可以做成一個簡單的在線相冊,只要把圖片放到images目錄,文件名按1-N命名,改一下代碼中的圖片總張數,就可以正常運行.

<!DOCTYPE html>
<html>
<meta charset=”utf-8″>
<script src=”js/jquery-1.7.2.min.js”></script>
<script>
$(function() {
var now = 1;
var p = “images/”;
var page=1;

$(‘#p’).click(function(){
now = now – 1;
if (now == 1) {
$(‘#p’).text(“”);

}
else {
$(‘#p’).text(“Pre”);
$(‘#n’).text(“Next”);
}

$(‘#pic’).attr(“src”,”images/” + now + “.jpg”);
});

$(‘#n’).click(function(){
now = now + 1;
if (now == 4) {
$(‘#n’).text(“”);

}
else {
$(‘#n’).text(“Next”);
$(‘#p’).text(“Pre”);
}

$(‘#pic’).attr(“src”,”images/” + now + “.jpg”);
});

$(‘#pic’).attr(“src”,”images/” + now + “.jpg”);

});
</script>
<body>
<div style=”width:980px;height:600px;overflow:scroll;”>
<img id=”pic” style=”width:1500px;” />
</div>
<table width=”50%”>
<tr>
<td>
<a id=”p” href=”#”></a>
</td>
<td>
<a id=”n” href=”#”>Next</a>
</td>
</tr>
</table>

</body>
</html>

 

发表在 Program | 标签为 , | 留下评论

angularjs and jquery ui datepicker not work

refer:

http://stackoverflow.com/questions/10727207/angularjs-jquery-ui-binding-issue

http://jsfiddle.net/9BRNf/2/

<input id=”date2″ value=”1/1/1980″ ng-model=”toDate” my-datepicker />
angular.module(‘myApp.directives’, [])
.directive(‘myDatepicker’, function() {
return function(scope, element, attrs) {

element.datepicker({
changeYear : true,
changeMonth : true,
appendText : ‘(yyyy-mm-dd)’,
dateFormat : ‘yy-mm-dd’,
onSelect: function(dateText, inst) {
var mdlAttr = $(this).attr(‘ng-model’);
scope[attrs.ngModel] = dateText;
scope.$apply();
}
});

}
});

发表在 Program | 标签为 , | 留下评论

HTML Table 固定表头简单实现

对于静态的表格,固定表头比较简单的实现方法,各浏览器下都可以显示,IE下,表头的栏线不是对得很齐.

浏览器: FireFox 13.1 , Chrome 18.1 , IE6,7,8.

特别注意的是,在IE下,第一行的代码一定要有,要不无法实现.

<!DOCTYPE   html   PUBLIC   “-//W3C//DTD   XHTML   1.0   Strict//EN”   “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title></title>
<style type=”text/css”>

.fixed {
background:   #ccc;
border-collapse:collapse;
border: 1px solid #0066ff;
/*position:absolute;*/
}

.scroll_layer   {
width:   500px;
height: 200px;
overflow:auto;

}

table { width:95%;}

</style>

</head>
<body>
<script type=”text/javascript” src=”jquery.js”>
</script><script type=”text/javascript”>

$(document).ready(function(){

function set_fixed_head(n)
{
$(“.fixed”).css(“position”,”static”);
var id = “#a” + n.toString();
var id_pre = “”;
var p ;
var s ;
if (n == 0)
{
p = $(id);
s = p.position();
$(id).css(“left”,s.left);
$(id).css(“width”,p.width() );
if ($.browser.msie)
{
$(id).css(“_width”,p.width() -0);    // for ie6
$(id).css(“*width”,p.width() -0);    // for ie7
var w8 = p.width() -3;
var v8 = w8.toString() + “px”;       // for ie8
$(id).attr(“style”,”width:” + v8 );
//alert( parseInt($.browser.version, 10) );
}

}
else
{
id_pre = “#a” + (n-1).toString();
p = $(id_pre);
s = p.position();
//$(id).css(“left”,s.left + $(id).width() );
$(id).css(“left”,$(id).position().left );
$(id).css(“width”, $(id).width() );
if ($.browser.msie)
{
//$(id).css(“left”,s.left + $(id).width() );
$(id).css(“_width”,$(id).width() -0);    // for ie6
$(id).css(“*width”,$(id).width() -0);    // for ie7
var w8 = $(id).width() -0;
var v8 = w8.toString() + “px”;       // for ie8 px\9 的ie hacker 无法运行,jquery.
$(id).css(“width”, $(id).width() );
}

}

}
set_head();

function set_head()
{
for (n = 0; n < 3; n++)
{
set_fixed_head(n);
}
$(“.fixed”).css(“position”,”absolute”);
//$(“.fixed”).css(“position”,”fixed”);

}
//$(window).resize( function() { set_head(); location.reload();});

});

</script>
<div>
<table border=”1″ bordercolor=”#0066FF” cellspacing=”0″ id=”table2″ >
<tr>
<td id=”a0″>
header1
</td>
<td id=”a1″>
header2
</td>
<td id=”a2″>
header3
</td>
</tr>

<tr>
<td>
body a
</td>
<td>
body b
</td>
<td>
body E
</td>
</tr>
<tr>
<td>
body c
</td>
<td>
body d
</td>
<td>
body E
</td>
</tr>
<tr>
<td>
body a
</td>
<td>
body b
</td>
<td>
body E
</td>
</tr>
<tr>
<td>
body c
</td>
<td>
body d
</td>
<td>
body E
</td>
</tr>
<tr>
<td>
body a
</td>
<td>
body b
</td>
<td>
body E
</td>
</tr>
<tr>
<td>
body c
</td>
<td>
body d
</td>
<td>
body E
</td>
</tr>
<tr>
<td>
body c
</td>
<td>
body d
</td>
<td>
body E
</td>
</tr>
<tr>
<td>
body c
</td>
<td>
body d
</td>
<td>
body E
</td>
</tr>
<tr>
<td>
body c
</td>
<td>
body d
</td>
<td>
body E
</td>
</tr>
<tr>
<td>
body c
</td>
<td>
body d
</td>
<td>
body E
</td>
</tr>
<tr>
<td>
body c
</td>
<td>
body d
</td>
<td>
body E
</td>
</tr>
<tr>
<td>
body c
</td>
<td>
body d
</td>
<td>
body E
</td>
</tr>
<tr>
<td>
body c
</td>
<td>
body d
</td>
<td>
body E
</td>
</tr>
<tr>
<td>
body c
</td>
<td>
body d
</td>
<td>
body E
</td>
</tr>
<tr>
<td>
body c
</td>
<td>
body d
</td>
<td>
body E
</td>
</tr>

</table>
</div>

</body>
</html>

 

发表在 Program, 网站 | 标签为 , , | 留下评论