Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

SQLÅúÁ¿¸ü¸ÄÓû§±íÄÚ×Ö·ûÐÍ×ֶεÄÅÅÐò¹æÔò

--------------------------------------------------------------------------
--  Author : htl258(Tony)
--  Date   : 2010-04-23 20:33:15
--  Version:Microsoft SQL Server 2008 (RTM) - 10.0.1600.22 (Intel X86)
--          Jul  9 2008 14:43:34
--          Copyright (c) 1988-2008 Microsoft Corporation
--          Developer Edition on Windows NT 5.1 <X86> (Build 2600: Service Pack 3)
--  Blog   : http://blog.csdn.net/htl258
--  Subject: ÅúÁ¿¸ü¸ÄÓû§±íÄÚ×Ö·ûÐÍ×ֶεÄÅÅÐò¹æÔò
--------------------------------------------------------------------------
DECLARE @S NVARCHAR(1000)
DECLARE C CURSOR FOR --²»Çø·Ö´óСд
    SELECT 'ALTER TABLE ['+B.NAME+'] ALTER COLUMN ['+A.NAME+'] '+ TYPE_NAME(A.XTYPE)+
        CASE WHEN TYPE_NAME(A.XTYPE) IN('TEXT','NTEXT') THEN '' ELSE
            QUOTENAME(A.LENGTH,'(')
        END +' COLLATE CHINESE_PRC_CI_AS' 
    from SYSCOLUMNS A
        JOIN SYSOBJECTS B ON A.ID=B.ID AND B.TYPE='U'
    WHERE TYPE_NAME(A.XTYPE) IN('VARCHAR','CHAR','NVARCHAR','NCHAR','TEXT','NTEXT')
OPEN C
FETCH C INTO @S
WHILE @@FETCH_STATUS=0
BEGIN
    EXEC(@S)
    FETCH C INTO @S
END
CLOSE C
DEALLOCATE C
GO
--×¢£ºÖ÷¼üÔ¼ÊøÓëÍâ¼üÔ¼ÊøµÄ×Ö¶ÎÔÚ´Ë´úÂëÖÐû¿¼ÂÇ¡£


Ïà¹ØÎĵµ£º

JAVAÁ¬½Ósql server 2005 Êý¾Ý¿âÐĵÃ

Ê×ÏȵÃÏÂÔØÇý¶¯³ÌÐòµ½Î¢ÈíÍøÕ¾ÏÂÔØMicrosoft SQL Server 2005 JDBC Driver 1.2
½âѹMicrosoft SQL Server 2005 jdbc driver1.2.exe£¬°Ñsqljdbc_1.1¸´ÖƵ½%ProgramFiles%£¨Èç¹ûϵͳÔÚCÅÌÔòΪC:\Program Files£©¡£
ÉèÖÃ Classpath
JDBC Çý¶¯³ÌÐò²¢Î´°üº¬ÔÚ Java SDK ÖС£Òò´Ë£¬Èç¹ûҪʹÓøÃÇý¶¯³ÌÐò£¬±ØÐ뽫 classpath ......

SQLº¯Êýµ÷ÓÃ

º¯ÊýÈçÏÂ
CREATE FUNCTION StockBalance_AmountIn(@SortID int)  
 RETURNS numeric(18,4)
AS  
BEGIN 
 Declare @dblReturn numeric(18,4)
 Select @dblReturn = SUM(AmountCurrentMonthIn) from AT_Materiel_StockBalance Where SortID = @SortID
 Return (@dblReturn)
END
......

sqlÓï¾ä¼¯½õ

Ò»¡¢Ö÷ÒªÊÇÐèÒª¸üÐÂmssqlServer µÄʱºòÐèÒª½øÐÐһЩÊÇ·ñ´æÔÚµÄÅжϣ¬ÔÚmssql2000 ºÍ 2005 ÉϲâÊÔûÓÐŶÎÊÌâ
--//ÅжÏÊDZíTable_UserInfoÀïÊÇ·ñÓÐ×Ö¶Î
if not exists(select * from syscolumns where id=object_id('Table_UserInfo') and name='Tel') begin
ALTER table Table_UserInfo add Tel varchar(200)--Ôö¼Ó×ֶΠ......

11 SQLµ÷ÓŸÅÊö

11.3µ÷ÓųÌÐò/¼õÇḺÔØ
Èç¹ûÆÚÍû¼õÇáÊý¾Ý¿â·þÎñÆ÷ÕûÌåµÄCPU»òÕßI/O¸ºÔØ£¬¿Éͨ¹ýÒÔϲ½ÖèÈ·¶¨×ÊÔ´Ãܼ¯Ð͵ÄSQLÓï¾ä£º
1.Ñ¡ÔñÔÚÓ¦ÓóÌÐòµÄ´¦Àí¸ß·åÆÚ¼ì²â¡£
2.ÔÚÒÔÉÏÖÜÆÚÄÚ£¬ÊÕ¼¯²Ù×÷ϵͳ¼°Oracleͳ¼ÆÐÅÏ¢¡£ÐèÒªÊÕ¼¯µÄOracleͳ¼ÆÐÅÏ¢ÖÁÉÙ°üÀ¨ÎļþµÄI/O£¨Í¨¹ýÊÓͼV$FILESTAT£©£¬ÏµÍ³Í³¼ÆÐÅÏ¢£¨V$SYSSTAT£©£¬ÒÔ¼°SQLͳ¼ÆÐÅÏ¢£ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ