in

SDT Community Server

SDT Forums, Blogs, Photos server.

Floating Heart

No description is bad.

August 2008 - Posts

  • 警惕二十九岁现象

    http://blog.sina.com.cn/s/blog_4864a3c9010005lj.html

       大家都知道“59岁现象”――许多国企的老总年龄接近60岁时,一改过去勤恳、节俭的本色,盖因在60岁国企老总法定退休年龄之前,他们心态失衡;而“29岁现象”却鲜为人知,但在中国“29岁现象”比“59岁现象”普遍得多。

          什么是“29岁现象”?
          我在多年培养、使用年轻人尤其是大学生的过程中发现:不少员工在20多岁时,学习工作有激情,工作上勤勤垦垦、踏踏实实,生活有艺术、有情趣,可是到了29岁左右,按说应该更成熟更有价值才对,但反而情绪波动大、工作浮躁急功近利。表现在看书、学习注意力不集中,对外界事物的兴趣忽高忽低,设定的工作目标或高不可攀或放弃追求,对下属或要求过分或听之任之,对亲友不耐烦,对团队尤其是对上级经常抱怨牢骚,对待批评建议经常没有耐性甚至反应过分激烈,老虎屁股摸不得,经常比过去,讲排场慕虚荣,对自己过去的同学朋友羞于提起现在的职位或收入,内心经常将自己与认识不认识的姣姣者做不切实际的比较,比较之后往往自惭形秽、自怨自艾、自我放逐,严重者陷入重度抑郁症。生活没情趣、工作无效率,经常是心里着急行动却无力无效,就像人们梦中经常遇到的紧急情况:想跑迈不开腿,向动动不了,想说张不开嘴,人际关系不是冷漠就是紧张。

      过去30岁这个坎之后,这类人有两种结局,一种原来就乐观、平和的,通过及时努力调整一切正常化了。但有很大一部分人挣扎抗争不过,就此消极麻木、一副万事皆休、死猪不怕开水烫的架式。

      这又是什么原因呢?我注意到这种状况多发生在30岁左右时,找他们分析原因,他们自已也不是很清楚,但是经常听到这种人哀叹:“快30岁了,成了家没立业,什么时候立得起来呢?我什么时候能像你们一样?”

      三十还没立业!对我触动很大,记得我30左右的时候,虽然没有明显上述症状,但也因功未成名不就,失衡焦虑了好一阵,好在及时用“阿Q精神抚慰疗法”调整过来了,都是“三十而立”这句古语害了大家!

      20多岁时,都知道是打基础的时候,要想今后有成就,现在就要多付出,心态较平和,也有一定的耐心;当快要到30岁时,眼看自己的梦想和追求的结果没能达到社会上讲得“立业”的期望和标准时,对父母不好交待,不好意思见同学朋友,自己无法面对,自己给自己制造很多无形的压力,而且越来越大。

      那什么是社会的“立业”标准为呢?我认为是人们对三十而立要达到的社会期望水平过高。改革开放初期各行业充满了机会,各专业也因沉寂了十年,所以到转型期很多人一夜暴富。时代对77、78级80年代的毕业生格外惠顾,给他们创造了快速立业的机遇,成名成家相对容易;而到90年代末和21世纪,社会经济发展有了一定的基础,各行各业向专业化推进,而且社会竞争变得越来越激烈,这时成名立业的周期在拉长,进入门槛一再提高。
         

      现代社会“五十而立,三十知天命”
          针对29岁现象,前些年我提出了“五十而立,三十知天命”的观点,受到了许多朋友的欢迎。古代人均寿命50岁左右,30生命过多半,此时不立则晚矣,如50岁时再不知天乐命,则只有苦熬余生了。而现代人平均寿命已到70岁左右,古代的30岁相当于现在的40-50岁,而且由于知识爆炸、竞争激烈,各专业行当更加复杂化,变数更多,人到40-50岁才能到达事业的高峰。30岁左右时,有的人刚刚拿到博士学位,创业者刚刚挣脱困境赚个温饱;许多公务员刚刚摆脱端茶倒水、打零杂的状态;普通工薪阶层生存问题刚刚得到解决(房价、教育等社会成本增高)。提出“五十而立”是让多数年轻人放平心态,期望不要太高,压力不要太大,不要过分急躁;提出了“三十知天命”,恰恰是因为这个年龄更需要及早知天乐命,看清人生大道,不违天命(自然法则、社会潮流、人生使命)这套理论通过各种论坛和大学演讲,反响很好,还真救了不少人。
           但后来我仔细阅读《论语》中孔子的原话,“吾十有五而志于学,三十而立,四十而不惑,五十而知天命,六十而耳顺,七十而从心所欲,不逾矩。”发觉我原来的论点有些缺乏依据,如孔子讲的“30而立”中的“立”指的不是立业,而是立志立身,衔结前后两句就能明白。他的意思是说,我15岁开始做学问,30岁立志(周游列国,布道授业),40岁左右时学问习精,不再受外界诱惑而偏离方向。无论是学问不惑还是人生方向不惑,都不是现代意义上的“立业”层面。大家知道,所谓人生三立——立德、立功、立言。对于孔子来讲,立德算在40多岁后周游列国,50多岁弟子3000,贤人72;立功是孔子在68岁归鲁方被尊以“国老”之后;而立言呢,在公元前722年讫于公元前479年即孔子卒年间,孔子修订六经(《易》、《诗》、《书》、《礼》、《乐》、《春秋》),真正的立言不朽之作《论语》是在他去世后弟子们整理的。可见孔子的“立业”是很晚的。我常以此告诫那些视“30岁立业”为成功标尺的年轻人说:“圣人尚且如此,何况我等凡夫乎?”。
           我也拿我的例子(不敢与圣人相提并论,只是为了治病救人,不得已而为之)劝导安慰那些29岁症状的人说,我37岁才真正辞职,下海创办皇明公司是在1995年,当时不但是赤贫而且还负债近百万元,到了2000年也就是我42岁时,公司才有了盈余,但按照大家心目中“立业”的标准还差得很远,即使说立业也应是无论你的公司事业还是专业都立得住、站得固、走得稳。别说42岁时,就算我47岁退出管理一线之前,当我离开公司总裁岗位时,企业稳吗?企业立得住吗?我退出管理一线已近两年了,48岁近50岁了企业才有些“立”的迹象,企业文化、战略模式、管理机制等方面才有些大模样。然而管理体系上的“三机制两原则”虽然提出来了,但真正能可持续发展推行,稳定执行尚需时日,真正应了我提出了的“五十而立”。五十岁看清世事,知天达命;六十岁对反对意见也当音乐听;七十岁达到了思想的自由王国,怎样驰骋都不会超越铁的自然法则的。如果说一个人立与不立,大概这是一个分水岭吧。
           我想对年轻一代说的是,你们的梦想追求固然可以理解也值得尊重,但过于急于求成的心理是不切实际的、有害的。希望你们把梦想藏在心底,保持知足常乐、知天乐命又积极进取,相信付出总有回报的心态。走好走实人生的每一步,相信你们的人生能顶天立地,你们的事业能稳健而长足发展,年轻人,你们的路长着呢,一路走好!

    Posted Aug 31 2008, 12:06 PM by wicky with 1 comment(s)
    Filed under:
  • Oracle 11g Software Installation on Linux—CentOS-5

    http://www.jameskoopmann.com/docs/Install_Oracle11gCentOS5.htm
    Introduction

    This paper takes a look at installing Oracle 11g (11.1) on Linux (CentOS-5).You can read about CentOS at www.centos.org and be assured of its' Enterprise-class quality. This paper will use Oracle's Quick Installation Guide for Linux x86 as its' guide—noting where additional information may be obtained but getting Oracle installed on Linux as fast as possible. We at thecheapdba.com have years of experience installing Oracle—starting back with Oracle 7. We will point out best practices so that you end up with a reliable database that provides exceptional performance. We will occasionally re-visit, edit, and post additions to this paper as we find further configuration best practices.

    This paper will not cover the installation of CentOS-5 as that can be acquired through the CentOS website and additional Linux guides. We will however point out those alterations to the Linux environment that pertains to getting Oracle installed.

    Our goal is to provide you with the steps to properly install the Oracle 11g software without having to read Oracle's installation guide from front to back cover. We will provide you the commands to execute (just cut-n-paste) and the desired outcome of those commands. If you get something other than what is expected it would be time for you to re-visit earlier steps in this process. So hold on, here we go.

    It is assumed that the installer of Oracle software has access and is running on an X Window System workstation. Please consult X Server documentation if you need help. We at thecheapdba.com typically will use cygwin ( www.cygwin.com ) for all interfacing with our Linux distribution. It has an X Window System that works quite well—and as we always like is free.

     Checking Hardware RequirementsLog into the CentOS-5 system as the root user.For setting up the system to be used by Oracle there are a few prerequisites that must be checked and possibly changed by the root user. Log in as the root user and this document will tell you when it is time to switch from the root user to someone else.How much memorycommand: grep -i memtotal /proc/meminforesults: should be at least 1GB How much swapcommand: grep -i swaptotal /proc/meminforesults: should be 1.5 the size of memtotal if memtotal < 2GB         should be equal to memtotal if memtotal is between 2GB and 8GB         should be .75 the size of memtotal if memtotal > 8GB What processor typecommand: grep "model name" /proc/cpuinforesults: informationalHow much available RAM and swapcommand: freeresults: informational How much shared memory availablecommand: df -k /dev/shmresults: informationalpurpose: The shared memory should be sized to be at least the greater of MEMORY_MAX_TARGET and MEMORY_TARGET for each Oracle instance on the computer. How much disk space in /tmpcommand: df -k /tmpresults: should have at least 400MB available How much disk space for Oracle binariescommand: df -kresults: Depending on installation type you should have between 1.5GB and 3.5GB Checking Software RequirementsWhat distribution and version of Linux is installedcommand: cat /proc/versionresults: Linux version 2.6.18-8.1.15.el5 (mockbuild@builder6.centos.org)          (gcc version 4.1.1 20070105 (Red Hat 4.1.1-52))          #1 SMP Mon Oct 22 08:32:04 EDT 2007 What version of the kernel is installedcommand: uname -rresults: 2.6.18-8.1.15.el5  Are the following packages installed (assumes CentOS-5 and above distribution)command:rpm -q binutils \            compat-libstdc++ \            elfutils-libelf \            elfutils-libelf-devel \            glibc \            glibc-common \            glibc-devel \            glibc-headers \            gcc \            gcc-c++ \            libaio-devel \            libaio \            libgcc \            libstdc++ \            libstdc++ \            make \            sysstat \            unixODBC \            unixODBC-develresults: you will probably get quite a few packages that are not installed with a typical installation. You can investigate missing packages with the following command making sure you add/subtract from this list if necessary. yum list available "compat*" \                   "elfutils*" \                   "glibc*" \                   "gcc*" \                   "libaio*" \                   "sysstat*" \                   "unixODBC*"action : Our base installation left us needing to issue the following command to install missing packages.  yum -y install compat-libstdc++-296.i386 \               compat-libstdc++-33.i386 \               elfutils-libelf-devel.i386 \               glibc-devel.i386 \               glibc-headers.i386 \               gcc.i386 \               gcc-c++.i386 \               libaio-devel.i386 \               sysstat.i386 \               unixODBC.i386 \               unixODBC-devel.i386  Create Oracle user and groupCreate groups oinstall & dbacommand: /usr/sbin/groupadd oinstall         /usr/sbin/groupadd dba Create the Oracle and change passwordcommand: /usr/sbin/useradd -g oinstall -G dba -s /bin/bash oracle         /usr/bin/passwd oracle Validate the nobody user existscommand: /usr/bin/id nobodyresults: this user is almost always created on a base CentOS installation action : if this user is not created use the following command to create         /usr/sbin/useradd nobody Configuring kernel parametersThe following kernel parameters must be validated and possibly changed. Use the commands given below to view a particular kernel setting and then change if the setting is lower than the recommendation given in the following table.  You can make the changes by editing the /etc/sysctl.conf file and then rebooting the server. The following results are what we observed on our server and should not be expected on yours.

    shmmni

    4096
    shmall 2097152
    shmmax 2147483648
    semmsl 250
    semmns 32000
    semopm 100
    semmni 128
    file-max 65536
    ip_local_port_range 1024 - 65000
    rmem_default 1048576
    rmem_max 1048576
    wmem_default 262144
    wmem_max 262144
      command: /sbin/sysctl -a | grep kernel.semresults: kernel.sem = 250        32000   100     128 command: /sbin/sysctl -a | grep kernel.shmresults: kernel.shmmni = 4096         kernel.shmall = 268435456         kernel.shmmax = 4294967295 command: /sbin/sysctl -a | grep file-maxresults: fs.file-max = 102440 command: /sbin/sysctl -a | grep ip_local_port_rangeresults: net.ipv4.ip_local_port_range = 32768    61000 command: /sbin/sysctl -a | grep rmem_defaultresults: net.core.rmem_default = 109568 command: /sbin/sysctl -a | grep rmem_maxresults: net.core.rmem_max = 131071 command: /sbin/sysctl -a | grep wmem_defaultresults: net.core.wmem_default = 109568 command: /sbin/sysctl -a | grep wmem_maxresults: net.core.wmem_max = 131071 sample /etc/sysctl.conf file. This is given as an example only and does not reflect the results obtained above by the /sbin/sysctl commands. Only add lines that are needed and do not change any values to be lower than the base installation might have assigned. kernel.shmall = 2097152kernel.shmmax = 2147483648kernel.shmmni = 4096kernel.sem = 250 32000 100 128fs.file-max = 65536net.ipv4.ip_local_port_range = 1024 65000net.core.rmem_default = 4194304net.core.rmem_max = 4194304net.core.wmem_default = 262144net.core.wmem_max = 262144  Setting shell limits for the Oracle userAdd the following lines to /etc/security/limits.conforacle soft nproc  2047oracle hard nproc  16384oracle soft nofile 1024oracle hard nofile 65536 Add the following lines to /etc/pam.d/loginsession required /lib/security/pam_limits.sosession required pam_limits.so Add the following lines to /etc/profileif [ $USER = "oracle" ]; then  if [ $SHELL = "/bin/ksh" ]; then    ulimit -p 16384    ulimit -n 65536  else    ulimit -u 16384 -n 65536  fifi Creating Directories to Install the Oracle SoftwareValidate you have enough space on disk and choose a directory to install command: df -kresults: pick a mount point that has enough space—we have chosen /opt for the our. Create subdirectories and give permissions to the oracle userThe following directory used is common for Oracle installations. Note that we are creating all directories under /opt and that there are no other applications using /opt/app and below. This is very important as we are changing permissions with the following commands.command: mkdir -p /opt/app/oracle/product/11.1.0         chown -R oracle:oinstall /opt/app         chmod -R 775 /opt/app Switch to the oracle userUp to know we have been doing everything as the root user. It is now time to switch to the oracle user to actually install the Oracle software.command: su – oracleAdd the following line to $HOME/.bash_profileumask 022  Execute oracle's bash_profile to use new settingcommand: . ./.bash_profile Make sure the oracle user is using an X Windows System It is assumed you know how to set up an X Windows System as stated earlier in the document. Please verify it is working by issuing the xterm command and validating an X Terminal comes up. You may close the X Terminal if you wish. Set Oracle environment for the installationIssue the following commands to set/unset particular Oracle environments in preparation for the installation.command: export ORACLE_BASE=/opt/app/oracle         export ORACLE_SID=orcl         unset  ORACLE_HOME         unset  TNS_ADMINStart Oracle InstallerThis paper assumes you have downloaded the Oracle software from the net and have unzipped the files. We have unzipped our software into /opt and the following commands will take you through starting the Oracle installer form that mount point.command: cd /opt/database         ./runInstallerFrom this point, Oracle will do a few minor checks on the operating system and then put up the Oracle Installation screen. Our particular configuration did not throw any errors at this point but it should be noted, as it can be helpful, that sometimes the Oracle installer will complain at this very early stage about various Linux system configurations. If this is the case you might be able to bypass them by adding an additional argument to the runInstaller command. Please only use this as a last resort to the normal installation path.command: ./runInstaller -ignoreSysPrereqs From this point on we will walk through each of the prompts one at a time to give you a simple feel for a full installation of the Oracle software. Select installation method This screen is very busy to say the least. We are not going to create any databases at this point as it is not required nor is it suggested to do at this point. We like to create databases separately through the Database Creation Assistant (DBCA) and not confuse the software installation process. 1.    Choose basic installation1.    verify Oracle Base of '/opt/app/oracle'2.    verify Oracle Home of '/opt/app/oracle/product/11.1.0/db_1'3.    verify installation type of 'Enterprise Edition'4.    verify dba group of 'dba'2.    Un-check “Create Starter Database”3.    Un-check “Advanced Installation”4.    Click <NEXT> Specify Inventory directory and credentials1.    verify path of inventory directory of '/opt/app/oraInventory'2.    verify group name for install of 'oinstall'3.    Click <NEXT> Product-Specific Prerequisite ChecksThis screen, the installer will verify the system environment and report on any issues it may find. If all goes well you will get the status of 'Succeeded' for every check. Scroll through and make sure nothing has failed or look at the status box at the bottom of the screen and verify you get the following:'Check complete. The overall result of this check is: Passed'1.    verify all statuses2.    Click <NEXT> SummaryThis screen give a summary of the installation you are about to perform. It can be interesting to click and expand the products being installed to give you an idea of the what product and version is going to be installed.1.    validate 'Global Settings' for directories2.    validate 'Space Requirements'3.    Click <NEXT>  Install This screen gives a status of what is being installed. If all system settings have been properly set and all packages been installed properly then this should proceed without error. The status bar gives some indication of what is being installed at a particular point and the amount of work to be performed. But as all status bars you never really know how long in the process it is. 1.    Note the time it takes for specific products. If you notice one hanging or taking a long amount of time (greater than 10 minutes) you could have a condition that requires a pre-installation patch. Don't stop the installer yet but instead start looking for a bug / patch for the Oracle 11g installation process and the actual product being installed.2.    Execute Configuration scripts1.    open up a different terminal window2.    login as the root user3.    run /opt/app/oraInventory/orainstRoot.sh4.    run /opt/app/oracle/product/11.1.0/db_1/root.sh1.    accept default of /usr/local/bin5.    Click <OK>3.    Click <EXIT>4.    Click <YES> Cleanup1.    If you downloaded the software from the net you can now remove .zip file and the complete directory structure you unzipped it to. That particular command is not given here as it can be quite disastrous if executed from the wrong directory. 2.    Add the following lines to oracle's $HOME/.bash_profile file. This will allow you to execute various Oracle binaries to create databases, configure network settings, and generally manage the Oracle database environment.export ORACLE_HOME=/opt/app/oracle/product/11.1.0/db_1export PATH=$ORACLE_HOME/bin:$PATH Installation is complete Congratulations on a successful installation of the Oracle software. This paper hopefully was also successful in its attempt to guide you down a more simplistic path—giving you the commands to execute and working past the minor hurdles encountered during installation. Obviously this paper can not predict all the issues that you may encounter but if you have a relatively current system with ample memory and disk space there is no reason not to believe your installation wouldn't run smoothly.
    Posted Aug 25 2008, 05:10 PM by wicky with no comments
    Filed under:
  • 使用 PIVOT 和 UNPIVOT

    使用 PIVOT 和 UNPIVOT

    可以使用 PIVOT 和 UNPIVOT 关系运算符将表值表达式更改为另一个表。PIVOT 通过将表达式某一列中的唯一值转换为输出中的多个列来旋转表值表达式,并在必要时对最终输出中所需的任何其余列值执行聚合。UNPIVOT 与 PIVOT 执行相反的操作,将表值表达式的列转换为列值。

    注意:
    对升级到 SQL Server 2005 或更高版本的数据库使用 PIVOT 和 UNPIVOT 时,必须将数据库的兼容级别设置为 90 或更高。有关如何设置数据库兼容级别的信息,请参阅 sp_dbcmptlevel (Transact-SQL)

     

     

    PIVOT 提供的语法比一系列复杂的 SELECT...CASE 语句中所指定的语法更简单和更具可读性。有关 PIVOT 语法的完整说明,请参阅 FROM (Transact-SQL)

    以下是带批注的 PIVOT 语法。

    SELECT <non-pivoted column>,

        [first pivoted column] AS <column name>,

        [second pivoted column] AS <column name>,

        ...

        [last pivoted column] AS <column name>

    FROM

        (<SELECT query that produces the data>)

        AS <alias for the source query>

    PIVOT

    (

        <aggregation function>(<column being aggregated>)

    FOR

    [<column that contains the values that will become column headers>]

        IN ( [first pivoted column], [second pivoted column],

        ... [last pivoted column])

    ) AS <alias for the pivot table>

    <optional ORDER BY clause>;

    下面的代码示例生成一个两列四行的表。

    USE AdventureWorks ;
    GO
    SELECT DaysToManufacture, AVG(StandardCost) AS AverageCost 
    FROM Production.Product
    GROUP BY DaysToManufacture;
    

    下面是结果集:

    DaysToManufacture          AverageCost

    0                          5.0885

    1                          223.88

    2                          359.1082

    4                          949.4105

    没有定义 DaysToManufacture 为 3 的产品。

    以下代码显示相同的结果,该结果经过透视以使 DaysToManufacture 值成为列标题。提供一个列表示三 [3] 天,即使结果为 NULL

    -- Pivot table with one row and five columns
    SELECT 'AverageCost' AS Cost_Sorted_By_Production_Days, 
    [0], [1], [2], [3], [4]
    FROM
    (SELECT DaysToManufacture, StandardCost 
        FROM Production.Product) AS SourceTable
    PIVOT
    (
    AVG(StandardCost)
    FOR DaysToManufacture IN ([0], [1], [2], [3], [4])
    ) AS PivotTable;
    

    下面是结果集:

    Cost_Sorted_By_Production_Days    0         1         2           3       4       

    AverageCost                       5.0885    223.88    359.1082    NULL    949.4105

    可能会用到 PIVOT 的常见情况是:需要生成交叉表格报表以汇总数据。例如,假设需要在 AdventureWorks 示例数据库中查询 PurchaseOrderHeader 表以确定由某些特定雇员所下的采购订单数。以下查询提供了此报表(按供应商排序)。

    USE AdventureWorks;
    GO
    SELECT VendorID, [164] AS Emp1, [198] AS Emp2, [223] AS Emp3, [231] AS Emp4, [233] AS Emp5
    FROM 
    (SELECT PurchaseOrderID, EmployeeID, VendorID
    FROM Purchasing.PurchaseOrderHeader) p
    PIVOT
    (
    COUNT (PurchaseOrderID)
    FOR EmployeeID IN
    ( [164], [198], [223], [231], [233] )
    ) AS pvt
    ORDER BY pvt.VendorID;

    以下为部分结果集。

    VendorID    Emp1        Emp2        Emp3        Emp4        Emp5
    1           4           3           5           4           4
    2           4           1           5           5           5
    3           4           3           5           4           4
    4           4           2           5           5           4
    5           5           1           5           5           5

    将在 EmployeeID 列上透视此嵌套 select 语句返回的结果。

    SELECT PurchaseOrderID, EmployeeID, VendorID
    FROM PurchaseOrderHeader;

    这意味着 EmployeeID 列返回的唯一值自行变成了最终结果集中的字段。结果,在透视子句中指定的每个 EmployeeID 号都有相应的一列:在本例中为雇员 164198223231233PurchaseOrderID 列作为值列,将根据此列对最终输出中返回的列(称为分组列)进行分组。在本例中,通过 COUNT 函数聚合分组列。请注意,将显示一条警告消息,指出为每个雇员计算 COUNT 时未考虑显示在 PurchaseOrderID 列中的任何空值。

    重要提示:
    如果聚合函数与 PIVOT 一起使用,则计算聚合时将不考虑出现在值列中的任何空值。

     

     

    UNPIVOT 将与 PIVOT 执行几乎完全相反的操作,将列转换为行。假设以上示例中生成的表在数据库中存储为 pvt,并且您需要将列标识符 Emp1Emp2Emp3Emp4Emp5 旋转为对应于特定供应商的行值。这意味着必须标识另外两个列。包含要旋转的列值(Emp1Emp2...)的列将被称为 Employee,将保存当前位于待旋转列下的值的列被称为 Orders。这些列分别对应于 Transact-SQL 定义中的 pivot_columnvalue_column。以下为该查询。

    --Create the table and insert values as portrayed in the previous example.
    CREATE TABLE pvt (VendorID int, Emp1 int, Emp2 int,
        Emp3 int, Emp4 int, Emp5 int);
    GO
    INSERT INTO pvt VALUES (1,4,3,5,4,4);
    INSERT INTO pvt VALUES (2,4,1,5,5,5);
    INSERT INTO pvt VALUES (3,4,3,5,4,4);
    INSERT INTO pvt VALUES (4,4,2,5,5,4);
    INSERT INTO pvt VALUES (5,5,1,5,5,5);
    GO
    --Unpivot the table.
    SELECT VendorID, Employee, Orders
    FROM 
       (SELECT VendorID, Emp1, Emp2, Emp3, Emp4, Emp5
       FROM pvt) p
    UNPIVOT
       (Orders FOR Employee IN 
          (Emp1, Emp2, Emp3, Emp4, Emp5)
    )AS unpvt;
    GO

    以下为部分结果集。

    VendorID   Employee   Orders
    1      Emp1         4
    1      Emp2         3
    1      Emp3         5
    1      Emp4         4
    1      Emp5         4
    2      Emp1         4
    2      Emp2         1
    2      Emp3         5
    2      Emp4         5
    2      Emp5         5
    ...

    请注意,UNPIVOT 并不完全是 PIVOT 的逆操作。PIVOT 会执行一次聚合,从而将多个可能的行合并为输出中的单个行。而 UNPIVOT 不会重现原始表值表达式的结果,因为行已经被合并了。另外,UNPIVOT 的输入中的空值不会显示在输出中,而在执行 PIVOT 操作之前,输入中可能有原始的空值。

    AdventureWorks 示例数据库中的 Sales.vSalesPersonSalesByFiscalYears 视图将使用 PIVOT 返回每个销售人员在每个会计年度的总销售额。若要在 SQL Server Management Studio 中编写视图脚本,请在对象资源管理器中,在“视图”文件夹下找到 AdventureWorks 数据库对应的视图。右键单击该视图名称,再选择“编写视图脚本为”

    Posted Aug 23 2008, 01:09 PM by wicky with no comments
    Filed under:
  • "Not enough storage is available to complete this operation" in IE6 after installing VS2008 SP1

    Today I'm happy to install Visual Studio 2008 Service Pack 1. The installation is successful.
    But after that, my IE6(SP2) cannot work normally, error "Not enough storage is available to complete this operation" happens when:

    1) in Javascript, call window.showModalDialog, and in the opened page, access navigator.appCodeName, navigator.appVersion or navigator.userAgent
    2) click IE Help menu -> About

    After some searching and studying, I finally find some hints:
    http://www.technologyquestions.com/technology/windows-xp/205292-windows-update-problem.html

    The reason is User Agent too long! VS2008 SP1 add all CLR versions to user agent, and obviously, IE doesn't handle this correctly. See this picture
    User Agent

    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\User Agent\Post Platform]
    So it is easy to work around: I don't need .Net 3.0, just remove them and IE resume working.

     

    Posted Aug 12 2008, 10:05 PM by wicky with no comments
    Filed under:
  • Simple.Net at Google Sites

    New: http://sites.google.com/site/simpledotnet/Home, the old one (http://simpledotnet.googlepages.com) won't be updated any more ...

    Posted Aug 08 2008, 12:47 PM by wicky with no comments
    Filed under:
  • Microsoft SQL Server 2008 正式发布

    微软今天宣布正式发布SQL Server 2008服务器软件,这将帮助微软与Oracle 11g,IBM DB2 9.5数据库产品对抗.此前这一产品已经经过数次延期.
    SQL Server 2008出现在微软数据平台愿景上是因为它使得公司可以运行他们最关键任务的应用程序,同时降低了管理数据基础设施和发送观察和信息给所有用户的成本.目前SQL Server 2008 Express 和 SQL Server Compact版本都已经开始免费下载.

    http://www.microsoft.com/sqlserver/2008/en/us/product-information.aspx 

    Microsoft SQL Server 2008 provides a trusted, productive, and intelligent data platform that enables you to run your most demanding mission-critical applications, reduce time and cost of development and management of applications, and deliver actionable insight to your entire organization.

    • Learn the basics about Microsoft SQL Server 2008.

    • Learn about the features and benefits of using SQL Server 2008.

    • Complete a database comparison of SQL Server database against other database systems.

    • Find the edition of SQL Server 2008 that best suits your needs.

    • Read the latest news, press releases, and reviews about SQL Server 2008.

    • Get in-depth technical information about SQL Server 2008 features, benefits, and capabilities.

    • Take advantage of SQL Server 2008’s industry-leading performance and scalability for real-world database workloads with the lowest cost of operation, as verified by Microsoft partners and industry-standard Transaction Processing Performance Council’s TPC benchmarks.

    Posted Aug 07 2008, 08:44 AM by wicky with 1 comment(s)
    Filed under: