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

MSSQL ÓαêʹÓÃ

 ×ªÔØ http://www.jb51.net/article/17875.htm
      MS-SQLÓαêµÄʹÓü°Àí½â windows»òDOSµÄ“¹â±ê”²»Í¬£¬MS-SQLµÄÓαêÊÇÒ»ÖÖÁÙʱµÄÊý¾Ý¿â¶ÔÏ󣬼ȶԿÉÓÃÀ´Ðýת´¢´æÔÚϵͳÓÀ¾Ã±íÖеÄÊý¾ÝÐеĸ±±¾£¬Ò²¿ÉÒÔÖ¸Ïò´¢´æÔÚϵͳÓÀ¾Ã±íÖеÄÊý¾ÝÐÐ
ÓαêΪÄúÌṩÁËÔÚÖðÐеĻù´¡É϶ø²»ÊÇÒ»´Î´¦ÀíÕû¸ö½á¹û¼¯Îª»ù´¡µÄ²Ù×÷±íÖÐÊý¾ÝµÄ·½·¨¡£
1£®ÈçºÎʹÓÃÓαê
1£©¶¨ÒåÓαêÓï¾ä Declare <ÓαêÃû> Cursor For
2£©´´½¨ÓαêÓï¾ä Open <ÓαêÃû>
3£©ÌáÈ¡ÓαêÁÐÖµ¡¢Òƶ¯¼Ç¼ָÕë Fetch <ÁÐÃûÁбí> from <ÓαêÃû> [Into <±äÁ¿Áбí>]
4£©Ê¹ÓÃ@@Fetch_StatusÀûÓÃWhileÑ­»·´¦ÀíÓαêÖеÄÐÐ
5£©É¾³ýÓα겢ÊÍ·ÅÓï¾ä Close <ÓαêÃû>/Deallocate <ÓαêÃû>
6£©ÓαêÓ¦ÓÃʵÀý
--¶¨ÒåÓαê
Declare cur_Depart Cursor
For Select cDeptID,cDeptName from Department into @DeptID,@DeptName
--´´½¨Óαê
Open cur_Depart
--Òƶ¯»òÌáÈ¡ÁÐÖµ
Fetch from cur_Depart into @DeptID,@DeptName
--ÀûÓÃÑ­»·´¦ÀíÓαêÖеÄÁÐÖµ
While @@Fetch_Status=0
Begin
Print @DeptID,@DeptName
Fetch from cur_Depart into @DeptID,@DeptName
End
--¹Ø±Õ/ÊÍ·ÅÓαê
Close cur_Depart
Deallocate cur_Depart
2£®Óï¾äµÄÏêϸ¼°×¢Òâ
1£©¶¨ÒåÓαêÓï¾ä
Declare <ÓαêÃû> [Insensitive] [Scroll] Cursor
For <Select Óï¾ä> [FOR {Read Only | Update [ OF <ÁÐÃûÁбí>]}]
Insensitive DBMS´´½¨²éѯ½á¹û¼¯Êý¾ÝµÄÁÙʱ¸±±¾£¨¶ø²»ÊÇʹÓÃÖ±½ÓÒýÓÃÊý¾Ý¿â±íÖеÄÕæʵÊý¾ÝÐÐÖеÄÁУ©¡£ÓαêÊÇRead Only£¬Ò²¾ÍÊÇ˵²»ÄÜÐÞ¸ÄÆäÄÚÈÝ»òµ×²ã±íµÄÄÚÈÝ£»
Scroll Ö¸¶¨ÓαêÖ§³Öͨ¹ýʹÓÃÈÎÒâFetch Ñ¡ÏFirst Last Prior Next Relative Absolute£©Ñ¡È¡ËüµÄÈÎÒâÐÐ×÷Ϊµ±Ç°ÐС£Èç¹û´ËÏîÊ¡ÂÔ£¬ÔòÓα꽫ֻ֧³ÖÏòÏÂÒƶ¯µ¥ÐУ¨¼´Ö»Ö§³ÖÓαêµÄFetch Next£©£»
SelectÓï¾ä ¶¨ÒåÓαê½á¹û¼¯µÄ±ê×¼ SELECT Óï¾ä¡£ÔÚÓαêÉùÃ÷µÄ <SelectÓï¾ä>ÄÚ²»ÔÊÐíʹÓùؼü×Ö COMPUTE¡¢COMPUTE BY¡¢FOR BROWSE ºÍ INTO£»
Read Only ·ÀֹʹÓÃÓαêµÄÓû§Í¨¹ý¸üÐÂÊý¾Ý»òɾ³ýÐиıäÓαêµÄÄÚÈÝ£»
Update ´´½¨¿É¸üÐÂÓαêÇÒÁгöÖµÄܱ»¸üеÄÓαêÁС£Èç¹û×Ó¾äÖÐÁÐÈëÁËÈÎÒâÁУ¬ÔòÖ»Óб»ÁÐÈëµÄÁвÅÄܱ»¸üС£Èç¹ûDeclare CursorÓï¾äÖÐÖ»Ö¸¶¨µÄUPDATE£¨Ã»ÓÐÁÐÃûÁÐ±í£©£¬ÔòÓα꽫ÔÊÐí¸üÐÂËüµÄÈκλòË


Ïà¹ØÎĵµ£º

MSSQLÊý¾Ý¿âÊý¾ÝÀàÐÍ


 
    Êý¾ÝÀàÐÍ
 
 ÀàÐÍ
 
 ÃèÊö
 
bit
 
ÕûÐÍ
 
bit Êý¾ÝÀàÐÍÊÇÕûÐÍ£¬ÆäÖµÖ»ÄÜÊÇ0¡¢1»ò¿ÕÖµ¡£ÕâÖÖÊý¾ÝÀàÐÍÓÃÓÚ´æ´¢Ö»ÓÐÁ½ÖÖ¿ÉÄÜÖµµÄÊý¾Ý £¬ÈçYes »òNo¡¢True »òFa lse ¡¢On »òOff
int
 
ÕûÐÍ
 
int Êý¾ÝÀàÐÍ¿ÉÒÔ´æ´¢´Ó- 231( ......

MSSQLÌí¼Ó×Ö¶Î˵Ã÷

--×Ö¶ÎÌí¼Ó˵Ã÷
EXEC sp_addextendedproperty 'MS_Description', 'ÒªÌí¼ÓµÄ˵Ã÷', 'user', dbo, 'table', ±íÃû, 'column', ÁÐÃû
--ɾ³ý×Ö¶Î˵Ã÷
EXEC sp_dropextendedproperty 'MS_Description', 'user', dbo, 'table', ±íÃû, 'column', ×Ö¶ÎÃû
--²é¿´×Ö¶Î˵Ã÷
SELECT
    [Table Name] = i_s.TAB ......

.batÆô¶¯Êý¾Ý¿â·þÎñ(MSSQL,Oracle)

 @echo off
:dosmenu
REM Ñ¡Ôñ²Ëµ¥
echo  Windows ·þÎñÆô¶¯»ò¹Ø±Õ By hope 2008Äê2ÔÂ7ÈÕ     
echo.
echo [1]Æô¶¯Sql Server2005   [2]¹Ø±ÕSql Server2005
echo [3]Æô¶¯Oracle9i         [4]¹Ø±ÕOracle9i
echo.
echo  ......

php 5.3 Á¬½ÓmssqlÊý¾Ý¿â

×î½üÓиöС¶«Î÷Òª²é¿´mssqlÊý¾Ý¿âÊÇÓÃphpʵÏֵģ¬ÒÔÇ°ÎÒÓÃphp5.2ʱ¸Ð¾õͦ¼òµ¥µÄËùÒÔÏëphp5.3Ò²Ó¦¸ÃºÜ¼òµ¥µÄ
ΪʲôҪÓÃphp5.3ÄØÒòΪÎÒÏëÓÃsqlite3.0µÄ°¡£¬ÒòΪphp5.2µÄ²»Ö§³Ösqlite3.0µÄ°¡£¬ËùÒÔÎÒÌØÒâÈ¥ÏÂÁË5.3ÁËÏÂÔØ»ØÀ´Á˲ŷ¢ÏÖ5.3ÀïûÓÐmssqlµÄdllÀ©Õ¹ÁË£¬ÓôÃÆ°¡£¬²»¹ÜÕâô¶àÏÈÓÃÆðÄÇsqlite3.0ÔÙ˵ÁË
sqlite3.0µÄ²¿·Ö ......

MSSQLÊý¾Ý¿â²Ù×÷ʹÓÃÓï¾ä


1.°´ÐÕÊϱʻ­ÅÅÐò: 
Select * from TableName Order By CustomerName Collate Chinese_PRC_Stroke_ci_as 
2.·ÖÒ³SQLÓï¾ä 
select * from(select (row_number() OVER (ORDER BY tab.ID Desc)) as rownum,tab.* from ±íÃû As tab) As t where rownum between ÆðʼλÖà And ½áÊøλÖà
3.»ñÈ¡µ±Ç°Êý¾ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ