﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-sealyu</title><link>http://www.blogjava.net/sealyu/</link><description /><language>zh-cn</language><lastBuildDate>Wed, 09 Jul 2008 12:32:15 GMT</lastBuildDate><pubDate>Wed, 09 Jul 2008 12:32:15 GMT</pubDate><ttl>60</ttl><item><title>SQL Server日期处理datetime和date之间的相互转换</title><link>http://www.blogjava.net/sealyu/archive/2008/07/03/212308.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Thu, 03 Jul 2008 05:38:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2008/07/03/212308.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/212308.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2008/07/03/212308.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/212308.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/212308.html</trackback:ping><description><![CDATA[<p><font size="1"><span>日期是数据处理中经常使用到的信息之一。生日、数据处理时间、计划的预计完成时间，按年、季、月的统
计，这些都属于日期处理的范畴。由于日期中包含了年、季、月、日等众多信息，不同的国家对日期格式、日期文字描述及星期有不同的规定，因此产生了日期处理
的复杂性。本章主要讨论在</span>SQL Server数据库中对日期的各种处理方法。</font></p>
<h2 align="center"><font face="宋体, MS Song" size="1">日期类型概述</font></h2>
<p><font size="1">SQL Server中的日期类型包括datetime和smalldatetime，仅能处理可以识别为1753年～9999年间的日期的值，没有单独的日期型或时间型。</font></p>
<h4><font face="宋体, MS Song"><font size="1">1．datetime</font></font></h4>
<p><font size="1">datetime类型处理从1753年1月1日～9999年12月31日的日期和时间数据，精确度为百分之三秒。即：对于0.000～0.001、0.009的日期值，调整为0.000；对于0.002～0.004的日期值，调整为0.003；对于0.005～0.008的日期值，调整为0.007。</font></p>
<p><font size="1">例如，下面的代码在输入时，其时间精确度为百分之一秒，但经数据库保存后再显示出来，其结果就已经做了处理。</font></p>
<p><font face="Courier New" size="1">DECLARE @t TABLE(date char(21))</font></p>
<p><font face="Courier New" size="1">INSERT @t SELECT '1900-1-1 00:00:00.000'</font></p>
<p><font face="Courier New" size="1">...</font></p>
<p><font face="Courier New" size="1">INSERT @t SELECT '1900-1-1 00:00:00.009'</font></p>
<p><font size="1"><font face="Courier New">SELECT date,</font>转换后的日期<font face="Courier New">=CAST(date as datetime) FROM @t</font></font></p>
<p><font size="1"><font face="Courier New">/*--</font>结果</font></p>
<p><font size="1"><font face="Courier New">date&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font>转换后的日期</font></p>
<p><font face="Courier New" size="1">---------------------------------- ----------------------------</font></p>
<p><font face="Courier New" size="1">1900-1-1 00:00:00.000&nbsp;&nbsp;&nbsp; 1900-01-01 00:00:00.000<br />
...<br />
<font face="Courier New">1900-1-1 00:00:00.000&nbsp;&nbsp;&nbsp; 1900-01-01 00:00:00.010</font><br />
</font></p>
<font size="1"><font face="Courier New">--*/</font> </font>
<p><font size="1">datetime的存储长度为8字节，日期和时间各用4个字节存储，第一个4字节存储自1900年1月1日之前或之后的天数（以1900年1月1日为分界点，在1900年1月1日之前的日期的天数小于0，在1900年1月1日之后的日期的天数大于0）。另外一个4字节存储以午夜（00:00:00.000）后毫秒数所代表的每天的时间。</font></p>
<p><font size="1">例如，下面的代码演示了datetime变量中，仅包含单纯的日期和单纯的时间时，日期存储的十六进制存储表示结果。</font></p>
<p align="left"><font face="Courier New" size="1">DECLARE @dt datetime</font></p>
<p align="left"><font size="1"><font face="Courier New">--</font>单纯的日期</font></p>
<p align="left"><font face="Courier New" size="1">SET @dt='1900-1-2'</font></p>
<p align="left"><font face="Courier New" size="1">SELECT CAST(@dt as binary(8))</font></p>
<p align="left"><font size="1"><font face="Courier New">--</font>结果<font face="Courier New">: 0x0000000100000000</font></font></p>
<p align="left"><font size="1"><font face="Courier New">--</font>单纯的时间</font></p>
<p align="left"><font face="Courier New" size="1">SET @dt='00:00:01'</font></p>
<p align="left"><font face="Courier New" size="1">SELECT CAST(@dt as binary(8))</font></p>
<p align="left"><font size="1"><font face="Courier New">--</font>结果<font face="Courier New">: 0x000000000000012C</font></font></p>
<h4><font face="宋体, MS Song"><font size="1">2．smalldatetime</font></font></h4>
<p><font size="1">smalldatetime类型处理从1900年1月1日～2079年6月6 日的日期和时间数据，精确到分钟。29.998秒或更低的smalldatetime值向下舍入为最接近的分钟，29.999秒或更高的smalldatetime值向上舍入为最接近的分钟。</font></p>
<p><font size="1">smalldatetime的存储长度为4字节，第一个2字节存储自1900年1月1日之后的天数。另外一个2字节存储午夜（00:00:00.000）后的分钟数。</font></p>
<p><font size="1">例如，下面的代码演示了smalldatetime变量中，仅包含单纯的日期和单纯的时间时，日期存储的十六进制存储表示结果。</font></p>
<p><font face="Courier New" size="1">DECLARE @dt smalldatetime</font></p>
<p><font size="1"><font face="Courier New">--</font>单纯的日期</font></p>
<p><font face="Courier New" size="1">SET @dt='1900-1-2'</font></p>
<p><font face="Courier New" size="1">SELECT CAST(@dt as binary(4))</font></p>
<p><font size="1"><font face="Courier New">--</font>结果<font face="Courier New">: 0x00010000</font></font></p>
<p><font size="1"><font face="Courier New">--</font>单纯的时间</font></p>
<p><font face="Courier New" size="1">SET @dt='00:10'</font></p>
<p><font size="1"><font face="Courier New">SELECT CAST(@dt as binary(4))<br />
</font><font face="Courier New">--</font>结果<font face="Courier New">: 0x0000000A</font></font></p>
<h2><font face="宋体, MS Song" size="1">日期处理函数</font></h2>
<p><font size="1">日期由年、月、日、时等多个部分组成，它的处理相对复杂，因此，SQL Server提供了大量的日期处理函数，用以完成各种日期数据的处理。掌握好这些函数，对完成数据库的各种日期处理非常必要，本节将介绍几个常用的日期处理函数。期增减函数可以对日期指定部分的值进行增减，并返回处理后的日期值，SQL Server提供的日期增减函数为DATEADD。</font></p>
<p><br />
<font size="1">DATEADD</font><font size="1">的具体语法如下：<font face="Courier New">DATEADD ( datepart , number, date )</font></font></p>
<p><font size="1">其中包括以下参数。</font></p>
<p><font size="1">&#161;&nbsp;datepart：是规定应向日期的哪一部分返回新值的参数。表2-1列出了SQL Server支持的日期部分、缩写及含义。</font></p>
<p><font size="1"><font face="宋体, MS Song">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DATEADD</font>、<font face="宋体, MS Song">DATEDIFF</font>支持的日期部分、缩写及含义</font></p>
<table border="1" cellpadding="0" cellspacing="0" width="561">
    <tbody>
        <tr>
            <td valign="top" width="187">
            <p><font size="1">日期部分</font></p>
            </td>
            <td valign="top" width="187">
            <p><font size="1">缩<font face="宋体, MS Song">&nbsp;&nbsp;&nbsp; </font>写</font></p>
            </td>
            <td valign="top" width="187">
            <p><font size="1">含<font face="宋体, MS Song">&nbsp;&nbsp;&nbsp; </font>义</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="187">
            <p><font size="1">Year</font></p>
            </td>
            <td valign="top" width="187">
            <p><font size="1">yy , yyyy</font></p>
            </td>
            <td valign="top" width="187">
            <p><font size="1">年份</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="187">
            <p><font size="1">Quarter</font></p>
            </td>
            <td valign="top" width="187">
            <p><font size="1">qq , q</font></p>
            </td>
            <td valign="top" width="187">
            <p><font size="1">季度</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="187">
            <p><font size="1">Month</font></p>
            </td>
            <td valign="top" width="187">
            <p><font size="1">mm , m</font></p>
            </td>
            <td valign="top" width="187">
            <p><font size="1">月份</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="187">
            <p><font size="1">Dayofyear</font></p>
            </td>
            <td valign="top" width="187">
            <p><font size="1">dy,y</font></p>
            </td>
            <td rowspan="2" valign="top" width="187">
            <p><font size="1">日</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="187">
            <p><font size="1">Day</font></p>
            </td>
            <td valign="top" width="187">
            <p><font size="1">dd , d</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="187">
            <p><font size="1">Week</font></p>
            </td>
            <td valign="top" width="187">
            <p><font size="1">wk , ww</font></p>
            </td>
            <td valign="top" width="187">
            <p><font size="1">星期</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="187">
            <p><font size="1">Hour</font></p>
            </td>
            <td valign="top" width="187">
            <p><font size="1">Hh</font></p>
            </td>
            <td valign="top" width="187">
            <p><font size="1">小时</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="187">
            <p><font size="1">Minute</font></p>
            </td>
            <td valign="top" width="187">
            <p><font size="1">mi , n</font></p>
            </td>
            <td valign="top" width="187">
            <p><font size="1">分钟</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="187">
            <p><font size="1">Second</font></p>
            </td>
            <td valign="top" width="187">
            <p><font size="1">ss , s</font></p>
            </td>
            <td valign="top" width="187">
            <p><font size="1">秒</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="187">
            <p><font size="1">Millisecond</font></p>
            </td>
            <td valign="top" width="187">
            <p><font size="1">Ms</font></p>
            </td>
            <td valign="top" width="187">
            <p><font size="1">毫秒</font></p>
            </td>
        </tr>
    </tbody>
</table>
<p><font size="1">&#161;&nbsp;number：是用来增加datepart的值。正数表示增加，负数表示减少，如果指定的是非整数值，则忽略此值的小数部分，不做四舍五入处理。例如，DATEADD（Day,1.7,date），表示date增加1天。</font></p>
<p><font size="1">&#161;&nbsp;date：是返回datetime或smalldatetime值或日期格式字符串的表达式。</font></p>
<p><font size="1">如果date是smalldatetime，则返回smalldatetime，否则返回datetime。date为smalldatetime，Datepart为Second（ss,s）或Millisecond（ms）时，返回值将根据日期增减的结果调整到分钟；date为datetime，Datepart为Millisecond（ms）时，返回值将根据日期增减的结果调整为百分之三秒。调整规则可以参考2.1节的相关说明。</font></p>
<p><font size="1">date允许直接与number进行增减计算，即对于DATEADD（Day,number,date），等同于date+number。</font></p>
<h3><font face="宋体, MS Song"><font size="1">&nbsp;日期信息获取函数</font></font></h3>
<p><font size="1">日期信息获取函数用于获取日期指定部分的相关信息，常用的日期信息获取函数如表2-2所示。</font></p>
<p><font size="1"><font face="宋体, MS Song">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font>常用的日期信息获取函数</font></p>
<table border="1" cellpadding="0" cellspacing="0" width="561">
    <tbody>
        <tr>
            <td valign="top" width="140">
            <p><font size="1">功能说明</font></p>
            </td>
            <td valign="top" width="168">
            <p><font size="1">语<font face="宋体, MS Song">&nbsp;&nbsp;&nbsp; </font>法</font></p>
            </td>
            <td valign="top" width="253">
            <p><font size="1">参数及返回值数据类型说明</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="140">
            <p><font size="1">返回代表指定日期的指定日期部分的字符串</font></p>
            </td>
            <td valign="top" width="168">
            <p><font size="1">DATENAME(datepart,date)</font></p>
            </td>
            <td rowspan="2" width="253">
            <p><font size="1">datepart是指定应返回的日期部分的参数，其定义如表2-3所示。date是返回datetime或smalldatetime值或日期格式字符串的表达式。DATENAME函数返回nvarchar，DATEPART函数返回int</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="140">
            <p><font size="1">返回代表指定日期的指定日期部分的整数</font></p>
            </td>
            <td valign="top" width="168">
            <p><font size="1">DATEPART(datepart,date)</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="140">
            <p><font size="1">返回表示指定日期中的年份的整数</font></p>
            </td>
            <td valign="top" width="168">
            <p><font size="1">YEAR(date)</font></p>
            </td>
            <td valign="top" width="253">
            <p><font size="1">返回int</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="140">
            <p><font size="1">返回表示指定日期中的月份的整数</font></p>
            </td>
            <td valign="top" width="168">
            <p><font size="1">MONTH(date)</font></p>
            </td>
            <td valign="top" width="253">
            <p><font size="1">返回int</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="140">
            <p><font size="1">返回表示指定日期中的天的整数</font></p>
            </td>
            <td valign="top" width="168">
            <p><font size="1">DAY(date)</font></p>
            </td>
            <td valign="top" width="253">
            <p><font size="1">返回int</font></p>
            </td>
        </tr>
    </tbody>
</table>
<p><font size="1"><font face="宋体, MS Song">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DATENAME</font>、<font face="宋体, MS Song">DATEPART</font>支持的日期部分、缩写及含义</font></p>
<table border="1" cellpadding="0" cellspacing="0" width="561">
    <tbody>
        <tr>
            <td valign="top" width="140">
            <p><font size="1">日期部分</font></p>
            </td>
            <td valign="top" width="168">
            <p><font size="1">缩<font face="宋体, MS Song">&nbsp;&nbsp;&nbsp; </font>写</font></p>
            </td>
            <td valign="top" width="253">
            <p><font size="1">含<font face="宋体, MS Song">&nbsp;&nbsp;&nbsp; </font>义</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="140">
            <p><font size="1">Year</font></p>
            </td>
            <td valign="top" width="168">
            <p><font size="1">yy , yyyy</font></p>
            </td>
            <td valign="top" width="253">
            <p><font size="1">年份</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="140">
            <p><font size="1">Quarter</font></p>
            </td>
            <td valign="top" width="168">
            <p><font size="1">qq , q</font></p>
            </td>
            <td valign="top" width="253">
            <p><font size="1">季度</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="140">
            <p><font size="1">Month</font></p>
            </td>
            <td valign="top" width="168">
            <p><font size="1">mm , m</font></p>
            </td>
            <td valign="top" width="253">
            <p><font size="1">月份</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="140">
            <p><font size="1">Dayofyear</font></p>
            </td>
            <td valign="top" width="168">
            <p><font size="1">dy , y</font></p>
            </td>
            <td rowspan="2" valign="top" width="253">
            <p><font size="1">日</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="140">
            <p><font size="1">Day</font></p>
            </td>
            <td valign="top" width="168">
            <p><font size="1">dd , d</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="140">
            <p><font size="1">Week</font></p>
            </td>
            <td valign="top" width="168">
            <p><font size="1">wk , ww</font></p>
            </td>
            <td valign="top" width="253">
            <p><font size="1">自年初开始的第几个星期</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="140">
            <p><font size="1">Weekday</font></p>
            </td>
            <td valign="top" width="168">
            <p><font size="1">Dw</font></p>
            </td>
            <td valign="top" width="253">
            <p><font size="1">星期几（例如星期一、星期二）</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="140">
            <p><font size="1">Hour</font></p>
            </td>
            <td valign="top" width="168">
            <p><font size="1">Hh</font></p>
            </td>
            <td valign="top" width="253">
            <p><font size="1">小时</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="140">
            <p><font size="1">Minute</font></p>
            </td>
            <td valign="top" width="168">
            <p><font size="1">mi , n</font></p>
            </td>
            <td valign="top" width="253">
            <p><font size="1">分钟</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="140">
            <p><font size="1">Second</font></p>
            </td>
            <td valign="top" width="168">
            <p><font size="1">ss , s</font></p>
            </td>
            <td valign="top" width="253">
            <p><font size="1">秒。date为smalldatetime时，始终返回0</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="140">
            <p><font size="1">Millisecond</font></p>
            </td>
            <td valign="top" width="168">
            <p><font size="1">Ms</font></p>
            </td>
            <td valign="top" width="253">
            <p><font size="1">毫秒。date为smalldatetime时，始终返回0，为datetime时，返回百份之三秒</font></p>
            </td>
        </tr>
    </tbody>
</table>
<p><font size="1">DATEPART（Week,date）返回的星期计算方式，是按照星期日为一周的第一天，这点与中国人的日期处理习惯不同，在使用时要注意这一点。DATENAME函数返回指定日期的指定日期部分的字符串，其返回的具体字符串值，与SET DATEFIRST及SET DATELANGUAGE选项的设置有关。使用DATEPART（Weekday,date）时，其返回的值与SET DATEFIRST选项的设置有关，具体的将在2.3节中说明。</font></p>
<h3><font face="宋体, MS Song"><font size="1">&nbsp;日期差值计算函数</font></font></h3>
<p><font size="1">日期差值计算函数用于计算两个给定日期指定部分的边界数，SQL Server提供的日期差值计算函数为DATEDIFF。</font></p>
<p><font size="1">DATEDIFF的具体语法如下：</font></p>
<p><font face="Courier New" size="1">DATEDIFF ( datepart , startdate , enddate ) </font></p>
<p><font size="1">其中包括以下参数。</font></p>
<p><font size="1">&#161;&nbsp;datepart：规定了应在日期的哪一部分计算差额，其定义如表2-1所示。</font></p>
<p><font size="1">&#161;&nbsp;startdate：规定了计算的开始日期。</font></p>
<p><font size="1">&#161;&nbsp;enddate：规定了计算的终止日期。</font></p>
<p><font size="1">返回类型：integer</font></p>
<p><font size="1">计算的开始日期和终止日期，可以是日期或日期格式的字符串。计算的方法是从enddate减去startdate。如果startdate比enddate晚，返回负值。当结果超出整数值范围，DATEDIFF就产生错误。对于毫秒，最大数是24天20小时31分钟23.647秒。对于秒，最大数是68年。</font></p>
<p><font size="1">计算跨分钟、秒和毫秒这些边界的方法，使得DATEDIFF给出的结果在全部数据类型中是一致的。结果是带正负号的整数值，其等于跨第一个和第二个日期间的datepart边界数。例如，在2005年1月4日和2005年2月11日之间的月份数是1。</font></p>
<h3><font face="宋体, MS Song"><font size="1">&nbsp;其他日期处理相关函数</font></font></h3>
<p><font size="1">其他常用的日期处理相关函数包括以下几个。</font></p>
<h4><font face="宋体, MS Song"><font size="1">1．GETDATE</font></font></h4>
<p><font size="1">GETDATE按照datetime值返回当前系统日期和时间。</font></p>
<p><font size="1">GETDATE的语法如下：</font></p>
<p><font face="Courier New" size="1">GETDATE()</font></p>
<p><font size="1">返回类型：datetime</font></p>
<h4><font face="宋体, MS Song"><font size="1">2．ISDATE</font></font></h4>
<p><font size="1">ISDATE确定输入的表达式是否有效日期。</font></p>
<p><font size="1">在输入日期表达式时，日期都是以日期格式的字符串提供的，由于不同的区域有不同的日期格式，所以并不能保证输入的日期表达式能够被SQL Server识别，这种情况下，就需要用ISDATE来判断日期表达式能否正确地被SQL Server识别了。</font></p>
<p><font size="1">ISDATE的语法如下：</font></p>
<p><font face="Courier New" size="1">ISDATE(expression)</font></p>
<p><font size="1">返回类型：int</font></p>
<h4><font face="宋体, MS Song"><font size="1">3．CONVERT</font></font></h4>
<p><font size="1">CONVERT将某种数据类型的表达式显式转换为另一种数据类型。</font></p>
<p><font size="1">严格来说，CONVERT不属于日期处理函数，只是它被经常用于日期处理中，所以这里把它列入了其他日期处理函数，下面是CONVERT的用法描述（只重点说明在日期处理中的应用）。</font></p>
<p><font size="1">CONVERT的具体语法如下：</font></p>
<p><font face="Courier New" size="1">CONVERT ( data_type [ ( length ) ] , expression [ , style ] )</font></p>
<p><font size="1">其中包括以下参数。</font></p>
<p><font size="1">&#161;&nbsp;expression：是要转换数据类型的有效SQL Server表达式。</font></p>
<p><font size="1">&#161;&nbsp;data_type：是expression转换后的数据类型，length是对于有精度定义需要的data_type的精度定义，对于没有精度定义需要的data_type，该参数可以省略。</font></p>
<p><font size="1">&#161;&nbsp;style：定义数据类型转换时的格式，对于日期类型的转换，它的定义如表2-4所示。</font></p>
<p><font size="1">表<font face="宋体, MS Song">2-4 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; style</font>在日期转换中的说明</font></p>
<table border="1" cellpadding="0" cellspacing="0" width="561">
    <tbody>
        <tr>
            <td valign="top" width="105">
            <p><font size="1">不带世纪数位</font></p>
            </td>
            <td valign="top" width="84">
            <p><font size="1">带世纪数位</font></p>
            </td>
            <td valign="top" width="141">
            <p><font size="1">标<font face="宋体, MS Song">&nbsp;&nbsp;&nbsp; </font>准</font></p>
            </td>
            <td valign="top" width="230">
            <p><font size="1">输入<font face="宋体, MS Song">/</font>输出</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="105">
            <p align="center"><font size="1">—</font></p>
            </td>
            <td valign="top" width="84">
            <p align="center"><font size="1">0或100</font></p>
            </td>
            <td valign="top" width="141">
            <p><font size="1">默认值</font></p>
            </td>
            <td valign="top" width="230">
            <p><font size="1">mon dd yyyy hh:miAM(或 PM)</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="105">
            <p align="center"><font size="1">1</font></p>
            </td>
            <td valign="top" width="84">
            <p align="center"><font size="1">101</font></p>
            </td>
            <td valign="top" width="141">
            <p><font size="1">美国</font></p>
            </td>
            <td valign="top" width="230">
            <p><font size="1">mm/dd/yyyy</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="105">
            <p align="center"><font size="1">2</font></p>
            </td>
            <td valign="top" width="84">
            <p align="center"><font size="1">102</font></p>
            </td>
            <td valign="top" width="141">
            <p><font size="1">ANSI</font></p>
            </td>
            <td valign="top" width="230">
            <p><font size="1">yy.mm.dd</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="105">
            <p align="center"><font size="1">3</font></p>
            </td>
            <td valign="top" width="84">
            <p align="center"><font size="1">103</font></p>
            </td>
            <td valign="top" width="141">
            <p><font size="1">英国/法国</font></p>
            </td>
            <td valign="top" width="230">
            <p><font size="1">dd/mm/yy</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="105">
            <p align="center"><font size="1">4</font></p>
            </td>
            <td valign="top" width="84">
            <p align="center"><font size="1">104</font></p>
            </td>
            <td valign="top" width="141">
            <p><font size="1">德国</font></p>
            </td>
            <td valign="top" width="230">
            <p><font size="1">dd.mm.yy</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="105">
            <p align="center"><font size="1">5</font></p>
            </td>
            <td valign="top" width="84">
            <p align="center"><font size="1">105</font></p>
            </td>
            <td valign="top" width="141">
            <p><font size="1">意大利</font></p>
            </td>
            <td valign="top" width="230">
            <p><font size="1">dd-mm-yy</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="105">
            <p align="center"><font size="1">6</font></p>
            </td>
            <td valign="top" width="84">
            <p align="center"><font size="1">106</font></p>
            </td>
            <td valign="top" width="141">
            <p><font size="1">—</font></p>
            </td>
            <td valign="top" width="230">
            <p><font size="1">dd mon yy</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="105">
            <p align="center"><font size="1">7</font></p>
            </td>
            <td valign="top" width="84">
            <p align="center"><font size="1">107</font></p>
            </td>
            <td valign="top" width="141">
            <p><font size="1">—</font></p>
            </td>
            <td valign="top" width="230">
            <p><font size="1">mon dd, yy</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="105">
            <p align="center"><font size="1">8</font></p>
            </td>
            <td valign="top" width="84">
            <p align="center"><font size="1">108</font></p>
            </td>
            <td valign="top" width="141">
            <p><font size="1">—</font></p>
            </td>
            <td valign="top" width="230">
            <p><font size="1">hh:mm:ss</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="105">
            <p align="center"><font size="1">—</font></p>
            </td>
            <td valign="top" width="84">
            <p align="center"><font size="1">9或109</font></p>
            </td>
            <td valign="top" width="141">
            <p><font size="1">默认值+毫秒</font></p>
            </td>
            <td valign="top" width="230">
            <p><font size="1">mon dd yyyy hh:mi:ss:mmmAM(或PM)</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="105">
            <p align="center"><font size="1">10</font></p>
            </td>
            <td valign="top" width="84">
            <p align="center"><font size="1">110</font></p>
            </td>
            <td valign="top" width="141">
            <p><font size="1">美国</font></p>
            </td>
            <td valign="top" width="230">
            <p><font size="1">mm-dd-yy</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="105">
            <p align="center"><font size="1">11</font></p>
            </td>
            <td valign="top" width="84">
            <p align="center"><font size="1">111</font></p>
            </td>
            <td valign="top" width="141">
            <p><font size="1">日本</font></p>
            </td>
            <td valign="top" width="230">
            <p><font size="1">yy/mm/dd</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="105">
            <p align="center"><font size="1">12</font></p>
            </td>
            <td valign="top" width="84">
            <p align="center"><font size="1">112</font></p>
            </td>
            <td valign="top" width="141">
            <p><font size="1">ISO</font></p>
            </td>
            <td valign="top" width="230">
            <p><font size="1">yymmdd</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="105">
            <p align="center"><font size="1">—</font></p>
            </td>
            <td valign="top" width="84">
            <p align="center"><font size="1">13或113</font></p>
            </td>
            <td valign="top" width="141">
            <p><font size="1">欧洲默认值+毫秒</font></p>
            </td>
            <td valign="top" width="230">
            <p><font size="1">dd mon yyyy hh:mm:ss:mmm(24h)</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="105">
            <p align="center"><font size="1">14</font></p>
            </td>
            <td valign="top" width="84">
            <p align="center"><font size="1">114</font></p>
            </td>
            <td valign="top" width="141">
            <p><font size="1">—</font></p>
            </td>
            <td valign="top" width="230">
            <p><font size="1">hh:mi:ss:mmm(24h)</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="105">
            <p align="center"><font size="1">—</font></p>
            </td>
            <td valign="top" width="84">
            <p align="center"><font size="1">20或120</font></p>
            </td>
            <td valign="top" width="141">
            <p><font size="1">ODBC规范</font></p>
            </td>
            <td valign="top" width="230">
            <p><font size="1">yyyy-mm-dd hh:mm:ss[.fff]</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="105">
            <p align="center"><font size="1">—</font></p>
            </td>
            <td valign="top" width="84">
            <p align="center"><font size="1">21或121</font></p>
            </td>
            <td valign="top" width="141">
            <p><font size="1">ODBC规范（带毫秒）</font></p>
            </td>
            <td valign="top" width="230">
            <p><font size="1">yyyy-mm-dd hh:mm:ss[.fff]</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="105">
            <p align="center"><font size="1">—</font></p>
            </td>
            <td valign="top" width="84">
            <p align="center"><font size="1">126</font></p>
            </td>
            <td valign="top" width="141">
            <p><font size="1">ISO8601</font></p>
            </td>
            <td valign="top" width="230">
            <p><font size="1">yyyy-mm-ddThh:mm:ss.mmm</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="105">
            <p align="center"><font size="1">—</font></p>
            </td>
            <td valign="top" width="84">
            <p align="center"><font size="1">130</font></p>
            </td>
            <td valign="top" width="141">
            <p><font size="1">Hijri</font></p>
            </td>
            <td valign="top" width="230">
            <p><font size="1">dd mon yyyy hh:mi:ss:mmmAM</font></p>
            </td>
        </tr>
        <tr>
            <td valign="top" width="105">
            <p align="center"><font size="1">—</font></p>
            </td>
            <td valign="top" width="84">
            <p align="center"><font size="1">131</font></p>
            </td>
            <td valign="top" width="141">
            <p><font size="1">Hijri</font></p>
            </td>
            <td valign="top" width="230">
            <p><font size="1">dd/mm/yy hh:mi:ss:mmmAM</font></p>
            </td>
        </tr>
    </tbody>
</table>
<div>
<p><font size="1">说明<font face="宋体, MS Song">：</font></font></p>
<p><font face="宋体, MS Song" size="1">①&nbsp;输入/输出：&#8220;输入&#8221;表示从字符串转换为日期时字符串的日期格式，&#8220;输出&#8221;指从日期转换为字符串时的日期字符串格式。</font></p>
<p><font face="宋体, MS Song" size="1">②&nbsp;Hijri：是具有几种变化形式的日历系统，SQL Server使用其中的科威特算法。</font></p>
</div>
<p><font size="1">当从smalldatetime转换为字符数据时，由于smalldatetimer只保存到分钟的数据，因此，对于包含秒或毫秒的样式，将在秒或毫秒的位置上显示零。当从datetime或smalldatetime值进行转换时，可以通过使用适当的char或varchar数据类型长度来截断不需要的日期部分。</font></p>
<div>
<p><font size="1">注意<font face="宋体, MS Song">：</font></font></p>
<p><font face="宋体, MS Song" size="1">在SQL Server中，由于直接提供的日期均是以日期格式的字符串提供，所以在使用CONVERT进行日期格式转换时，要先把日期格式的字符串转换为日期型，然后才能利用CONVERT进行日期格式转换，否则就变成字符串转换为字符串，此时的style选项是无效的。</font></p>
</div>
<p><font size="1">返回类型：由参数data_type确定。</font></p>
<p><font size="1">下面是利用CONVERT进行日期转换的简单示例：</font></p>
<p><font size="1"><font face="Courier New">/*== </font>字符转换为日期时<font face="Courier New">,Style</font>的使用<font face="Courier New"> ==*/</font></font></p>
<p><font size="1"><font face="Courier New">--1. Style=101</font>时<font face="Courier New">,</font>表示日期字符串为<font face="Courier New">:mm/dd/yyyy</font>格式</font></p>
<p><font face="Courier New" size="1">SELECT CONVERT(datetime,'11/1/2003',101)</font></p>
<p><font size="1"><font face="Courier New">--</font>结果<font face="Courier New">:2003-11-01 00:00:00.000</font></font></p>
<p><font size="1"><font face="Courier New">--2. Style=101</font>时<font face="Courier New">,</font>表示日期字符串为<font face="Courier New">:dd/mm/yyyy</font>格式</font></p>
<p><font face="Courier New" size="1">SELECT CONVERT(datetime,'11/1/2003',103)</font></p>
<p><font size="1"><font face="Courier New">--</font>结果<font face="Courier New">:2003-01-11 00:00:00.000</font><font face="Courier New">&nbsp;</font></font></p>
<p><font size="1"><font face="Courier New">/*== </font>日期转换为字符串<font face="Courier New"> ==*/</font></font></p>
<p><font face="Courier New" size="1">DECLARE @dt datetime</font></p>
<p><font face="Courier New" size="1">SET @dt='2003-1-11'</font></p>
<p><font size="1"><font face="Courier New">--1. Style=101</font>时<font face="Courier New">,</font>表示将日期转换为<font face="Courier New">:mm/dd/yyyy </font>格式</font></p>
<p><font face="Courier New" size="1">SELECT CONVERT(varchar,@dt,101)</font></p>
<p><font size="1"><font face="Courier New">--</font>结果<font face="Courier New">:01/11/2003</font></font></p>
<p><font size="1"><font face="Courier New">--2. Style=103</font>时<font face="Courier New">,</font>表示将日期转换为<font face="Courier New">:dd/mm/yyyy </font>格式</font></p>
<p><font face="Courier New" size="1">SELECT CONVERT(varchar,@dt,103)</font></p>
<p><font size="1"><font face="Courier New">--</font>结果<font face="Courier New">:11/01/2003</font></font></p>
<p><font size="1"><font face="Courier New">&nbsp;</font><font face="Courier New">/*== </font>这是很多人经常犯的错误<font face="Courier New">,</font>对非日期型转换使用日期的<font face="Courier New">style</font>样式<font face="Courier New"> ==*/</font></font></p>
<p><font face="Courier New" size="1">SELECT CONVERT(varchar,'2003-1-11',101)</font></p>
<font size="1"><font face="Courier New">--</font>结果</font><font face="Courier New" size="1">:2003-1-11</font>
<img src ="http://www.blogjava.net/sealyu/aggbug/212308.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2008-07-03 13:38 <a href="http://www.blogjava.net/sealyu/archive/2008/07/03/212308.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SQL Server 2005 error: Connection Refused:connect</title><link>http://www.blogjava.net/sealyu/archive/2008/07/01/212000.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Tue, 01 Jul 2008 13:07:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2008/07/01/212000.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/212000.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2008/07/01/212000.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/212000.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/212000.html</trackback:ping><description><![CDATA[在安装了开发版的SQL Server2005 后，可以从Management Studio里面进行所有的操作，但是通过jdbc连接时出现错误：<br />
<font style="font-size: 14px;">Connection&nbsp;refused:&nbsp;connect<br />
经过几小时的挣扎，在配置管理器里面发现了问题，原来是TCPIP服务没有默认打开，解决如下：<br />
</font><font style="font-size: 14px;">1、打开SQL&nbsp;Server&nbsp;Configuration&nbsp;Manager&nbsp;-&gt;&nbsp;Protocols&nbsp;for&nbsp;SQLEXPRESS&nbsp;-&gt;&nbsp;TCP/IP<br />
2、右键单击启动TCP/IP<br />
3、双击进入属性，把IP地址中的IP&nbsp;all中的TCP端口设置为1433<br />
4、重新启动SQL&nbsp;Server&nbsp;2005服务</font><br />
<br />
<img src ="http://www.blogjava.net/sealyu/aggbug/212000.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2008-07-01 21:07 <a href="http://www.blogjava.net/sealyu/archive/2008/07/01/212000.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>删除ubuntu冗余启动菜单</title><link>http://www.blogjava.net/sealyu/archive/2008/06/16/208349.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Mon, 16 Jun 2008 07:39:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2008/06/16/208349.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/208349.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2008/06/16/208349.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/208349.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/208349.html</trackback:ping><description><![CDATA[<p><font size="3">ubuntu<span>启动菜单，有时候更新完系统，grub菜单上会多几个Ubuntu
linux等选项,而这些选项可以说都是没有什么用的,会造成一些麻烦.</span></font></p>
<p><font size="3">解决方法很简单,只要用新立得搜索一下linux-image，把不需要的核心去掉，保留最新的版本就可以了。最后记得把/boot/grub/menu.lst下的</font></p>
<p><font size="3"><span>default&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp; X</span></font></p>
<p><font size="3">修改成自己想要默认启动的项的序号,序号是以0开始记数的</font></p>
<img src ="http://www.blogjava.net/sealyu/aggbug/208349.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2008-06-16 15:39 <a href="http://www.blogjava.net/sealyu/archive/2008/06/16/208349.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SQL Server 2005 错误：“The transaction log for database '@dbname' is full” 的解决方法</title><link>http://www.blogjava.net/sealyu/archive/2008/05/13/200199.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Tue, 13 May 2008 06:53:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2008/05/13/200199.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/200199.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2008/05/13/200199.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/200199.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/200199.html</trackback:ping><description><![CDATA[<p>Sometimes, we might encounter such error from SSIS:</p>
<p><span style="font-size: 10pt; color: red; line-height: 115%; font-family: 'MS Shell Dlg','sans-serif';">The transaction log for database <a style="color: red;" href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#37;&#50;&#55;&#64;&#100;&#98;&#110;&#97;&#109;&#101;&#37;&#50;&#55;">'@dbname'</a> is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.databases</span></p>
<p><strong><span style="font-size: 12pt; line-height: 115%;">Cause:</span></strong></p>
<p>To find out available free space of transaction log file:</p>
<p>Object Explorer <span style="font-family: Wingdings;">&#224;</span>SQL Server instance<span style="font-family: Wingdings;">&#224;</span>Database<span style="font-family: Wingdings;">&#224;</span>right click on task-&gt;shrink-&gt;files<span style="font-family: Wingdings;">&#224;</span>choose File Type as Log<span style="font-family: Wingdings;">&#224;</span>Check below &#8220;Available Free Space&#8221;</p>
<p>The % of Available Free Space should be 0%.</p>
<p>View current settings of database by running this T-SQL command:</p>
<span style="font-size: 10pt; color: black; line-height: 115%; font-family: 'Courier New';">
<p><font color="#800000" size="2">&nbsp;&nbsp;&nbsp;&nbsp;sp_helpdb</font><font size="2"> [ [ @dbname= ] </font><font color="#ff0000" size="2">'name'</font><font size="2"> ]<br />
<br />
</font></p>
</span>View <strong>size</strong> and <strong>growth</strong> column for log file.
<p>Next, find Location of the log file and log on to SQL server
machine. We should verify if there is no enough space for this log file
to be allocated (free space &lt; <strong>growth</strong>)</p>
<strong><span style="font-size: 12pt; line-height: 115%;">Resolution</span></strong>:
<p>Object Explorer <span style="font-family: Wingdings;">&#224;</span>SQL Server instance<span style="font-family: Wingdings;">&#224;</span>Database<span style="font-family: Wingdings;">&#224;</span>right click on Property <span style="font-family: Wingdings;">&#224;</span>Choose Files <span style="font-family: Wingdings;">&#224;</span></p>
<blockquote dir="ltr" style="margin-right: 0px;">
<p style="text-indent: -0.25in;">Option 1.<span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Add one more log file</p>
<p style="text-indent: -0.25in;">Option 2.<span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Truncate original log file to a lower size(with this option, you will lose log message)</p>
</blockquote>
<p>Run TSQL command with Alter database:</p>
<span style="font-size: 10pt; color: blue; line-height: 115%; font-family: 'Courier New';">ALTER</span><span style="font-size: 10pt; line-height: 115%; font-family: 'Courier New';"> <span style="color: blue;">DATABASE </span>@dbname <span style="color: blue;">MODIFY</span> <span style="color: blue;">FILE</span> <span style="color: gray;">(</span> <span style="color: blue;">NAME</span> <span style="color: gray;">=</span> N<span style="color: red;">'GDS_Log_1'</span><span style="color: gray;">,</span> <span style="color: blue;">SIZE</span> <span style="color: gray;">=</span> 1925120KB <span style="color: gray;">)</span></span>
<img src ="http://www.blogjava.net/sealyu/aggbug/200199.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2008-05-13 14:53 <a href="http://www.blogjava.net/sealyu/archive/2008/05/13/200199.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Interceptor 中onFlushDirty()函数执行多次的问题（Hibernate 的一个小Bug）</title><link>http://www.blogjava.net/sealyu/archive/2008/05/09/199527.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Fri, 09 May 2008 07:59:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2008/05/09/199527.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/199527.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2008/05/09/199527.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/199527.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/199527.html</trackback:ping><description><![CDATA[最近在项目中遇到一个奇怪的问题，在使用Hibernate拦截器捕获实体变化并进行处理时，发现其中的onFlushDirty()函数执行了很多次，导致进行处理时产生很多重复数据。具体问题如下：<br />
使用一个类继承Hibernate的EmptyInterceptor类来对程序中的实体变化进行拦截，并在其中的onFlushDirty()函数中对捕获的数据进行处理，产生对应的event数据并保存到数据库中。 例如：<br />
public class EventInterceptor extends EmptyInterceptor {<br />
public boolean onFlushDirty(<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Object entity,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Serializable id,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Object[] currentState,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Object[] previousState,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String[] propertyNames,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Type[] types ) throws CallbackException {<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(isAuditable(entity)){//如果该实体需要被记录，生成对应的event。<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //此处生成对应的event。<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;<br />
&nbsp;&nbsp;&nbsp; }<br />
<br />
在程序执行后，发现对应一条实体的变化生成了多条重复的event记录，非常不解。<br />
后来google发现，有人也碰到过对应的问题，并在Hibernage论坛中提出过这个问题，鉴定为Hibernate的一个小Bug。<br />
（原文地址：http://forum.hibernate.org/viewtopic.php?t=940410&amp;highlight=interceptor+onflushdirty）<br />
解决方法如下：<br />
将FlushMode改为：FlushMode.COMMIT<br />
或者也可以提前进行flush()<br />
都可以解决这个问题。<br />
<br />
<img src ="http://www.blogjava.net/sealyu/aggbug/199527.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2008-05-09 15:59 <a href="http://www.blogjava.net/sealyu/archive/2008/05/09/199527.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>升级UBUNTU 7.10 到 8.04</title><link>http://www.blogjava.net/sealyu/archive/2008/04/28/196733.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Mon, 28 Apr 2008 05:17:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2008/04/28/196733.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/196733.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2008/04/28/196733.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/196733.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/196733.html</trackback:ping><description><![CDATA[今天将Ubuntu从 7.10版本升级到了8.04版本，<br />
实际上通过Ubuntu自带的更新管理器也可以升级到8.04， 但是速度比较慢。<br />
参照Ubuntu首页上的文档，采用直接从DVD光盘升级（如果你无法连接到网络，那你只能采取这种方法），方法如下：<br />
<ol>
    <li>
    <p>需要有一张Ubuntu的CD或者DVD盘。
    </p>
    </li>
    <li>
    <p>将光盘插入光驱
    </p>
    </li>
    <li>
    <p>打开终端，执行以下命令：</p>
    <pre>gksu "sh /cdrom/cdromupgrade" 将会弹出对应的升级对话框。（如果在Kubuntu下，执行：kdesu "sh /cdrom/cdromupgrade"）</pre>
    </li>
    <li>
    <p>按照提示进行升级。</p>
    </li>
</ol>
<br />
<img src ="http://www.blogjava.net/sealyu/aggbug/196733.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2008-04-28 13:17 <a href="http://www.blogjava.net/sealyu/archive/2008/04/28/196733.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>svn 版本库（Repository）迁移</title><link>http://www.blogjava.net/sealyu/archive/2008/04/24/195733.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Thu, 24 Apr 2008 13:47:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2008/04/24/195733.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/195733.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2008/04/24/195733.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/195733.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/195733.html</trackback:ping><description><![CDATA[今天服务器由于病毒的原因挂掉了，重装系统后需要恢复之前的版本库Repository。<br />
原来以后重装完svn后直接覆盖即可，但是并不起效果，依然是显示无法连接。<br />
后来发现版本库的迁移需要使用svnadmin 的dump命令，具体步骤如下：<br />
1. 将原来的Repository导出为一个文件dumpfile<br />
假设之前的版本库为E:\svnroot <br />
&gt; svnadmin dump E:\svnroot&gt;dumpfile
<br />
<br />
2. 创建新的Repository, 创建方法可以参考 Windows 平台安装Subversion server
<br />
<br />
3. 将dumpfile导入到新的Repository
<br />
&gt; svnadmin load E:\svnroot&lt;dumpfile
<br />
<br />
4.Enjoy it.....<br />
<img src ="http://www.blogjava.net/sealyu/aggbug/195733.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2008-04-24 21:47 <a href="http://www.blogjava.net/sealyu/archive/2008/04/24/195733.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SubVersion(SVN) 安装说明 </title><link>http://www.blogjava.net/sealyu/archive/2008/04/24/195637.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Thu, 24 Apr 2008 08:35:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2008/04/24/195637.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/195637.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2008/04/24/195637.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/195637.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/195637.html</trackback:ping><description><![CDATA[作者：sealyu<br />
1. 简介<br />
SubVersion 是新一代的版本控制工具，不仅可以管理程序源代码，而且也可用于文档或其他相关资料的管理。<br />
2. 下载<br />
svnsetup.exe&nbsp;&nbsp; http://subversion.tigris.org<br />
客户端TortoiseSVN http://tortoisesvn.net/downloads <br />
3. 安装步骤<br />
&nbsp; 1）安装刚才下载的软件<br />
&nbsp; 下面假设svnsetup的安装目录为<br />
&nbsp;C:\Program Files\Subversion<br />
&nbsp;您想建svn库的文件夹为 E:\svn<br />
&nbsp;&nbsp;<br />
&nbsp; 2）创建库<br />
&nbsp; 在E:\svn下，右键-》TortoiseSVN-&gt;Create Repository here.<br />
会在此文件夹下创建一个版本库，生成所需的文件。<br />
&nbsp; 3）创建为Windows自动运行的服务<br />
&nbsp; Subversion 从1.4版本开始，可以以windows系统服务的形式在开机时自动运行。但Subversion安装程序还不能把自己安装成windows服务，需要我们自己进行手动安装，方法如下： 打开一个DOS命令窗口，执行如下命令：　　<br />
sc create svnserve binPath= "\"C:\Program Files\Subversion\bin\svnserve.exe\" --service --root E:\svn" displayname= "Subversion Repository" depend= Tcpip start= auto 　　<br />
其中，sc是windows自带的服务配置程序，参数binPath表示svnserve可执行文件的安装路径，由于路径中的"Program Files"带有空格，因此整个路径需要用双引号引起来。而双引号本身是个特殊字符，需要进行转移，因此在路径前后的两个双引号都需要写成\"<br />
-- service参数表示以windows服务的形式运行，--root指明svn repository的位置，service参数与root参数都作为binPath的一部分，因此与svnserve.exe的路径一起被包含在一对双引号当中，而这对双引号不需要进行转义。<br />
displayname表示在windows服务列表中显示的名字， depend =Tcpip 表示svnserve服务的运行需要tcpip服务，start=auto表示开机后自动运行。　　<br />
安装服务后，svnserve要等下次开机时才会自动运行。　　<br />
若要卸载svn服务，则执行 sc delete svnserve 即可。 &nbsp;<br />
4）配置访问权限<br />
&nbsp;1 配置仓库<br />
SVN的svnserve对于每个仓库，有一个独立的配置文件和独立的用户、权限管理。<br />
在这里仍然要保持配置文件svnserve.conf的独立，但是用户、权限管理是用统一的一个文件来存储。<br />
这样方便以后的管理和维护。<br />
另外要注意，即使svnserve服务已经运行，修改配置文件或者用户、权限管理文件，保存后马上生效，不需要重启服务。<br />
假设已经配置两个仓库: source1和source2,都在E:\svn下.<br />
我们在E:\svn下放两个文件:passwd.conf 和authz.conf<br />
1.1 配置source1仓库<br />
进入仓库目录<br />
1.2 修改配置<br />
你可以直接删除默认的svnserve.conf文件，然后使用下面的配置：<br />
编辑svnserve.conf<br />
[general]<br />
anon-access = none <br />
auth-access = write<br />
password-db = ..\..\passwd<br />
authz-db = ..\..\authz<br />
realm = My First Repository<br />
说明：<br />
anon-access = none #不允许匿名用户访问<br />
auth-access = write #通过验证的用户可以读和写<br />
password-db = ..\..\passwd#用户保存文件<br />
authz-db = ..\..\authz#权限管理文件<br />
realm = My First Repository #仓库名称<br />
1.3 配置source2仓库<br />
进入仓库目录<br />
1.4 修改配置<br />
你可以直接删除默认的svnserve.conf文件，然后使用下面的配置：<br />
编辑svnserve.conf<br />
[general]<br />
anon-access = none <br />
auth-access = write<br />
password-db = ..\..\passwd<br />
authz-db = ..\..\authz<br />
realm = My Second Repository<br />
如果有更多的仓库，可以类推配置。<br />
----------------------------------------------------------------------<br />
svnserve.conf的原始内容：<br />
### This file controls the configuration of the svnserve daemon, if you<br />
### use it to allow access to this repository. (If you only allow<br />
### access through http: and/or file: URLs, then this file is<br />
### irrelevant.)<br />
### Visit http://subversion.tigris.org/ for more information.<br />
[general]<br />
### These options control access to the repository for unauthenticated<br />
### and authenticated users. Valid values are "write", "read",<br />
### and "none". The sample settings below are the defaults.<br />
# anon-access = read<br />
# auth-access = write<br />
### The password-db option controls the location of the password<br />
### database file. Unless you specify a path starting with a /,<br />
### the file's location is relative to the conf directory.<br />
### Uncomment the line below to use the default password file.<br />
# password-db = passwd<br />
### The authz-db option controls the location of the authorization<br />
### rules for path-based access control. Unless you specify a path<br />
### starting with a /, the file's location is relative to the conf<br />
### directory. If you don't specify an authz-db, no path-based access<br />
### control is done.<br />
### Uncomment the line below to use the default authorization file.<br />
# authz-db = authz<br />
### This option specifies the authentication realm of the repository.<br />
### If two repositories have the same authentication realm, they should<br />
### have the same password database, and vice versa. The default realm<br />
### is repository's uuid.<br />
# realm = My First Repository<br />
----------------------------------------------------------------------<br />
2 用户管理<br />
2.1 创建用户存储文件<br />
编辑passwd<br />
2.2 设置用户帐号<br />
[users]<br />
harry = harryssecret<br />
sally = sallyssecret<br />
bote = botessecret<br />
说明：<br />
[users] #是必须的，标记为用户配置开始<br />
harry = harryssecret # harry 是用户名 ， harryssecret是密码。注意，是明文密码<br />
sally = sallyssecret # 同上<br />
bote = botessecret # 同上<br />
往后所以仓库的用户都在这里记录就可以了。至于那个用户，允许访问那个仓库，在权限管理里限制。<br />
3 权限管理<br />
3. 1 创建权限管理文件<br />
编辑authz.conf<br />
3.2 设置权限管理<br />
[groups]<br />
source1 = harry<br />
source2 = sally<br />
[source1:/]<br />
@source1 = rw<br />
@source2 = r<br />
<br />
[source2:/]<br />
@source2 = rw<br />
bote = rw<br />
<br />
<img src ="http://www.blogjava.net/sealyu/aggbug/195637.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2008-04-24 16:35 <a href="http://www.blogjava.net/sealyu/archive/2008/04/24/195637.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>To Convert Your Sedentary Lifestyle (改变你久坐不动生活方式的14个简单方法 )</title><link>http://www.blogjava.net/sealyu/archive/2008/04/23/194925.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Wed, 23 Apr 2008 00:45:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2008/04/23/194925.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/194925.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2008/04/23/194925.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/194925.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/194925.html</trackback:ping><description><![CDATA[<p><span class="EC_style2"><font face="arial, helvetica, sans-serif" size="3"></font></span>&nbsp;</p>
<p><font face="arial, helvetica, sans-serif" size="3"></font>
<div><font face="arial, helvetica, sans-serif" size="3">We all know we need to exercise more &#8211; our lifestyles are way too sedentary compared to that of the previous generations. It's not all our fault. The days of the 9 to 5 job are long over and despite huge advances in technology, our lives seem to be a lot busier compared than that of previous generations.</font><font face="arial, helvetica, sans-serif" size="3">&nbsp;</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">Even when I have been motivated to get a gym membership and start exercising, it only lasts for a few months. At the first sign of stress and deadlines at work, the gym routine gets kicked off the list. So here are a few tricks to include some activity in daily habits to take it from a sedentary lifestyle to a mildly active one.</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">?&nbsp;&nbsp;&nbsp;&nbsp; Park far away: Instinctively, almost all of us look for a spot as close to our destination as possible. Instead get into the habit of parking a block away, or parking at the farthest parking spot. If you are grocery shopping, park in the store's lot but choose the back row. Clearly you wouldn't want to be caught pushing a shopping cart down the street trying to get to your car.</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">?&nbsp;&nbsp;&nbsp;&nbsp; Take the stairs instead of elevators: If it is one or two floors, always take the stairs. If you need to go up/down several floors then take the stairs to two floors above/below and then take the elevator. As you get used to it, increase the number of floors you use the stairs for. If you park in a level parking lot, always park in one of the higher levels and walk down.</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">?&nbsp;&nbsp;&nbsp;&nbsp; If possible, walk or bike to work: This is not possible for everyone, but if you live in a place where the pollution is less and your workplace is relatively close by, then choose to walk or bike instead of driving.</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">?&nbsp;&nbsp;&nbsp;&nbsp; Skip the stop: If your city has a subway or bus system, skip your stop and get off at the one after (or before) and then walk from there. You'll get to enjoy the air and neighborhood a little while increasing your heart rate.</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">?&nbsp;&nbsp;&nbsp; Maximize the benefits from your grocery trip: When you go to the grocery store, make it a habit to walk the entire store. Go through every aisle and every nook and corner. Avoid the aisles that could tempt you to pick up junk food though, since that can completely obliterate any benefits of walking a few extra steps! NOTE: if you have a spending problem don't do this.</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">?&nbsp;&nbsp;&nbsp;&nbsp; Take a short walk-break at work: Again this one depends on your work location, but ours is located outside the city and is on large private grounds. Every afternoon a couple of us go for a short walk (~1 mile round trip) which takes roughly 15-20 minutes. It is very invigorating and a nice break from the afternoon routine.</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">?&nbsp;&nbsp;&nbsp;&nbsp; Do your own yard work: This is a good one for summer time when the lawn starts to grow and you need to keep it trimmed. Instead of hiring someone to do it for you, do it yourself. You will not only get some exercise, but save some money too!</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">?&nbsp;&nbsp;&nbsp;&nbsp; Play with your kids: Kids these days seem to play more video games than outdoor games like we did when we were younger. So take your kids out to the park and throw the ball around, play tag, etc. </font></div>
<div><font face="arial, helvetica, sans-serif" size="3">?&nbsp;&nbsp;&nbsp;&nbsp; Put on your favorite music and dance: This is not only exercise, but also a great way to unwind at the end of a busy day. And a good trip down the memory lane for those of us who have not done it in a long time!</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">?&nbsp;&nbsp;&nbsp;&nbsp; While watching TV, pace or stretch: Instead of switching channels during the ad break get up and walk about the house. Do some lunges or some simple stretching exercises. If you have stairs in your house, walk up and down the stairs a few times, during each ad break for at least one show every day.</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">?&nbsp;&nbsp;&nbsp;&nbsp; Choose to walk down instead of call or email: When you have a question for a colleague, instead of picking up the phone or shooting an email, walk over to their cube. This will not only provide some exercise but a short break for a quick recharge.</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">?&nbsp;&nbsp;&nbsp;&nbsp; Walk while you talk on the phone: If your job involves talking on the phone a lot, then instead of doing this sitting at your desk, get into the habit of pacing while you talk. Motion creates emotion so you may even become a better speaker by doing this.</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">?&nbsp;&nbsp;&nbsp;&nbsp; Choose active entertainment over passive entertainment: Instead of going for a movie, choose to go play tennis with some friends (or at least bowling). Instead of playing regular video games, play with a Wii . Instead of meeting friends for a cup of coffee, catch up over a sunset walk.</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">?&nbsp;&nbsp;&nbsp;&nbsp; Choose active vacations: While planning vacations, pick something that involves some walking and hiking. While taking in a new city, do it by walk, instead of driving around. If golfing, skip the cart. If staying at a resort, make use of their pool and the exercise facility. Try skiing and white water rafting.</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">While none of these will make an immediate difference in your life style, over a period of time they will get you into the habit of choosing an active alternative to the every day things you do. In the long run, that can set the stage for an even more active life style and could be quite beneficial in avoiding some common health problems.</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">&nbsp;</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">众所周知，我们需要加强锻炼—比起我们的前辈，我们的生活方式更惯于久坐。这不全怪我们。每天早9晚5的工作时间很长，尽管科技日益发达，但比起我们的上一代，我们的生活似乎要忙碌得多。</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 我曾经受到鼓舞报名参加了体操训练，但那只维持了短短几个月时间。主要是由于工作的压力和期限限制，最终把体操训练从我的日志中划掉了。这里我从日常习惯中总结了一些包括活动的小技巧，它能使我们从久坐不动的生活方式中解脱出来，转变为适度活动的方式。</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 把车停得远一些：处于本能，我们都愿意寻找离目的地尽可能近的地方停车。那么不要习惯于把车停在只有一个街区远的地方，而要把它停在更远的地方，或者打在一个更远的停车场。如果你在商场购物，那么不要把车停在商店的区域，而选择停在后排。很明显，你不想被人看见推着购物车沿街寻找你的车。</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 爬楼梯而不乘电梯：如果在二、三楼，走楼梯好了。如果你需要上、下好几层楼，那么走两层楼梯再乘电梯。如果你已经习惯了，那么增加爬楼梯的层数。 如果你在一个阶梯停车场停车，要把车停在更高的一级，然后走着下来。</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 尽可能步行或骑自行车去上班：当然不是人皆适宜，但如果你居住的地方没什么污染，你工作的地方相对较近，那么选择步行或骑自行车，而不去驾车。</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 错过车站下车：如果你的城市有地铁或公交系统，那么你要错过你要到的车站，在前一站或其后一站下车，然后从那里走过去。当你的心率升高时，你要呼吸一下清新的空气，欣赏一下社区的风景。</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 在购物过程中获得最大的好处：当你去杂货店购物时，要养成逛遍整个杂货店的习惯。穿过每一条走廊，寻遍每一个角落。不要避免走那些引导你走向垃圾食品的走廊，这样可能破坏你多走几步的计划！注意：如果你存在消费问题，可别这样这么做耶。</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 在工作间隙做一下短暂散步：当然这又取决于你的工作场所了，而我们的工作场所坐落在城外，在一个很大的私人场地之上。每天下午，我们几个人都要做短暂散步（一里地行程），大约花15-20分钟。这非常令人神清气爽，在下午的工作中做了短暂休息。.</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 干你院子里的活儿：在夏季，当草坪开始生长时，这是一段好时光，你需要修剪它，不至于让它疯长。与其雇人，不如自己亲自干。这样不仅锻炼了身体而且节约了钱财，何乐而不为！</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 和孩子一起玩：现在的小孩子似乎总是躲在屋里玩电脑游戏而不像我们小时侯一样总是在户外活动。因此，带孩子到公园去，扔扔皮球，跳跳绳子等等。</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 播放你最喜欢的音乐，跳跳舞：这样不但能得到锻炼，而且能让我们从忙碌的日子中得到放松。在记忆中的乡间小路散步旅行，对于长时间没有光顾这里的我们，别有一番风味在心头。</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 看电视的时候踱踱步、伸伸腰。在看电视的间隙与其不停地换频道，还不如站起来在屋子里走走。如果你的屋子有楼梯，每天至少在一个电视剧间隙或广告时间，上下楼梯几次。</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 选择走过去，而不是打电话或发邮件：如果你有问题要问同事，不要拿起电话或发一个邮件，走向他的工作间。这不但能得到锻炼，而且还能稍做休息。</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 边走边打电话：如果你工作中接听电话的次数较多，那么不要坐在桌边接听，养成边迈步边打电话的习惯。行动促进心动，也许通过锻炼你会变得能说会道。</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 选择活动的娱乐方式而不是静坐的娱乐方式：不去看电影，而是和朋友一起打网球（至少是保龄球）。放弃定期玩电子游戏，而和朋友喝咖啡聊天，或在太阳的余辉中漫步。</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 选择度过一个充满活力的假期：当你计划度假时，挑一些散步或徒步旅行的项目去做。当你到一个新的城市度假，要步行观光、避免驾车去观光。能打高尔夫球就不去坐马车。如果你呆在一个旅游胜地，那么利用那里的池水和体育设施，千方百计去猾雪、划筏冲浪。</font></div>
<div><font face="arial, helvetica, sans-serif" size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 可能没有任何技巧能立即让你的生活方式改观，但通过一段时间，你就会养成选择积极的生活方式的习惯做日常生活的事。从长远来看，它能为你过上积极生活打下坚实基础，可以避免一些影响健康方面的问题发生，受益无穷。</font></div>
<img src ="http://www.blogjava.net/sealyu/aggbug/194925.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2008-04-23 08:45 <a href="http://www.blogjava.net/sealyu/archive/2008/04/23/194925.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>sql server 中删除默认约束的通用sql脚本</title><link>http://www.blogjava.net/sealyu/archive/2008/04/17/193755.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Thu, 17 Apr 2008 06:31:00 GMT</pubDate><guid>http://www.blogjava.net/sealyu/archive/2008/04/17/193755.html</guid><wfw:comment>http://www.blogjava.net/sealyu/comments/193755.html</wfw:comment><comments>http://www.blogjava.net/sealyu/archive/2008/04/17/193755.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sealyu/comments/commentRss/193755.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sealyu/services/trackbacks/193755.html</trackback:ping><description><![CDATA[在SQL Server 中，如果给表的一个字段设置了默认值，就会在系统表sysobjects中生成一个默认约束。<br />
如果想删除这个设置了默认值的字段（假设此字段名column1），<br />
执行&#8220;ALTER TABLE table1 DROP COLUMN column1&#8221;时就会报错：<br />
The object 'DF__xxxxxxxxxxx' is dependent on column 'column1'. <br />
ALTER TABLE DROP COLUMN column1failed because one or more objects access this column.<br />
<br />
所以在删除此字段时需要先将系统表中的对应默认约束删除， 可以使用下面的脚本进行删除：<br />
-- this script drops the default constraint which is generated by the setting of default value.<br />
DECLARE @tablename VARCHAR(100), @columnname VARCHAR(100), @tab VARCHAR(100)<br />
SET @tablename='CountryGroupEmailAndWaitAux'<br />
SET @columnname='actionOfHasNoValidEmail'<br />
<br />
declare @defname varchar(100)<br />
declare @cmd varchar(100)<br />
<br />
select @defname = name<br />
FROM sysobjects so <br />
JOIN sysconstraints sc<br />
ON so.id = sc.constid<br />
WHERE object_name(so.parent_obj) = @tablename<br />
AND so.xtype = 'D'<br />
AND sc.colid =<br />
(SELECT colid FROM syscolumns<br />
WHERE id = object_id(@tablename) AND<br />
name = @columnname)<br />
<br />
select @cmd='alter table '+ @tablename+ ' drop constraint '+ @defname<br />
if @cmd is null print 'No default constraint to drop'<br />
exec (@cmd)<br />
<br />
在删除对应的默认约束后，执行：<br />
ALTER TABLE table1 DROP COLUMN column1<br />
即可删除字段。<br />
<img src ="http://www.blogjava.net/sealyu/aggbug/193755.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sealyu/" target="_blank">seal</a> 2008-04-17 14:31 <a href="http://www.blogjava.net/sealyu/archive/2008/04/17/193755.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>