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

SqlServerÈ«¾Ö±äÁ¿±¸Íü


È«¾Ö±äÁ¿ÊÇSQL ServerϵͳÄÚ²¿ÊÂÏȶ¨ÒåºÃµÄ±äÁ¿£¬²»ÓÃÓû§²ÎÓ붨Ò壬¶ÔÓû§¶øÑÔ£¬Æä×÷Ó÷¶Î§²¢²»¾ÖÏÞÓÚijһ³ÌÐò£¬¶øÊÇÈκγÌÐò¾ù¿ÉËæʱµ÷Óá£È«¾Ö±äÁ¿Í¨³£ÓÃÓڴ洢һЩSQL ServerµÄÅäÖÃÉ趨ֵºÍЧÄÜͳ¼ÆÊý¾Ý¡£
SQL ServerÒ»¹²ÌṩÁË30¶à¸öÈ«¾Ö±äÁ¿£¬±¾½ÚÖ»¶ÔһЩ³£ÓñäÁ¿µÄ¹¦ÄܺÍʹÓ÷½·¨½øÐнéÉÜ¡£È«¾Ö±äÁ¿µÄÃû³Æ¶¼ÊÇÒÔ@@¿ªÍ·µÄ¡£
£¨1£©@@CONNECTIONS
¼Ç¼×Ô×îºóÒ»´Î·þÎñÆ÷Æô¶¯ÒÔÀ´£¬ËùÓÐÕë¶ÔÕą̂·þÎñÆ÷½øÐеÄÁ¬½ÓÊýÄ¿£¬°üÀ¨Ã»ÓÐÁ¬½Ó³É¹¦µÄ³¢ÊÔ¡£
ʹÓÃ@@CONNECTIONS¿ÉÒÔÈÃϵͳ¹ÜÀíÔ±ºÜÈÝÒ׵صõ½½ñÌìËùÓÐÊÔͼÁ¬½Ó±¾·þÎñÆ÷µÄÁ¬½ÓÊýÄ¿¡£
£¨2£©@@CUP_BUSY
¼Ç¼×ÔÉÏ´ÎÆô¶¯ÒÔÀ´³¢ÊÔµÄÁ¬½ÓÊý£¬ÎÞÂÛÁ¬½Ó³É¹¦»¹ÊÇʧ°Ü£¬¶¼ÒÔmsΪµ¥Î»µÄCPU¹¤×÷ʱ¼ä¡£
£¨3£©@@CURSOR_ROWS
·µ»ØÔÚ±¾´Î·þÎñÆ÷Á¬½ÓÖУ¬´ò¿ªÓαêÈ¡³öÊý¾ÝÐеÄÊýÄ¿¡£
£¨4£©@@DBTS
·µ»Øµ±Ç°Êý¾Ý¿âÖÐtimestampÊý¾ÝÀàÐ͵ĵ±Ç°Öµ¡£
£¨5£©@@ERROR
·µ»ØÖ´ÐÐÉÏÒ»ÌõTransact-SQLÓï¾äËù·µ»ØµÄ´íÎó´úÂë¡£
ÔÚSQL Server·þÎñÆ÷Ö´ÐÐÍêÒ»ÌõÓï¾äºó£¬Èç¹û¸ÃÓï¾äÖ´Ðгɹ¦£¬Ôò½«·µ»Ø@@ERRORµÄֵΪ0£¬Èç¹û¸ÃÓï¾äÖ´Ðйý³ÌÖз¢Éú´íÎó£¬Ôò½«·µ»Ø´íÎóµÄÐÅÏ¢£¬¶ø@@ERROR½«·µ»ØÏàÓ¦µÄ´íÎó±àºÅ£¬¸Ã±êºÅ½«Ò»Ö±±£³ÖÏÂÈ¥£¬Ö±µ½ÏÂÒ»ÌõÓï¾äµÃµ½Ö´ÐÐΪֹ¡£
ÓÉÓÚ@@ERRORÔÚÿһÌõÓï¾äÖ´Ðкó±»Çå³ý²¢ÇÒÖØÖã¬Ó¦ÔÚÓï¾äÑéÖ¤ºóÁ¢¼´¼ì²éËü£¬»ò½«Æä±£´æµ½Ò»¸ö¾Ö²¿±äÁ¿ÖÐÒÔ±¸Êºó²é¿´¡£
ʾÀý£º
ÔÚ“pubs”Êý¾Ý¿âÖÐÐ޸ēauthors”Êý¾Ý±íʱ£¬ÓÃ@@ERROR¼ì²âÏÞÖƲéѯ³åÍ»¡£
ͼ1  ÐÞ¸ÄÊý¾Ýʱ¼ì²â´íÎó
SQLÓï¾äÈçÏ£º
USE pubs
GO
UPDATE authors SET au_id = '172 32 1176'
WHERE au_id = '172-32-1176'
IF @@ERROR = 547
print 'A check constraint violation occurred'
£¨6£©@@FETCH_STATUS
·µ»ØÉÏÒ»´ÎʹÓÃÓαêFETCH²Ù×÷Ëù·µ»ØµÄ״ֵ̬£¬ÇÒ·µ»ØֵΪÕûÐÍ¡£
±í1  @@FETCH_STATUS·µ»ØÖµµÄÃèÊö
ÀýÈ磬µ½ÁË×îºóÒ»ÐÐÊý¾Ýºó£¬»¹Òª½Ó×ÅÈ¡ÏÂÒ»ÐÐÊý¾ÝµÈ£¬·µ»ØµÄֵΪ−2£¬±íʾ·µ»ØµÄÖµÒѾ­¶ªÊ§¡£
£¨7£©@@IDENTITY
·µ»Ø×î½üÒ»´Î²åÈëµÄidentityÁеÄÊýÖµ£¬·µ»ØÖµÊÇnumeric¡£
ʾÀý£º
ÔÚ“pugs”Êý¾Ý¿âÖеējobs”Êý¾Ý±íÖУ¬²åÈëÒ»ÐÐÊý¾Ý£¬²¢ÓÃ@@identityÏÔʾÐÂÐеıêʶֵ¡£SQLÓï¾äÈçÏ£º
USE pubs
INSERT INTO jobs (job_desc,min_lvl,max_lvl)
VALUES ('Accountant',12,125)
SELECT @@IDENTITY AS 'Identity'
£¨8£©@@IDLE
·µ»ØÒÔmsΪµ¥Î»¼ÆËãSQL Server·þÎñÆ÷×Ô


Ïà¹ØÎĵµ£º

sqlserver·ÖÒ³

ÏÖÔÚÒ»°ã³£ÓõÄÓÐÒÔÏÂ2ÖÖ·½·¨:
1. select top @pagesize * from table1 where id not in  (select top @pagesize*(@page-1) id  from table1 order by id) order by id
2. select *  from (select top @pagesize * from (select top @pagesize*@page * from table1 order by id) a order by id desc) b or ......

SQLServerʱ¼äÈÕÆÚº¯ÊýÏê½â,SQLServer,ʱ¼äÈÕÆÚ,


SQLServerʱ¼äÈÕÆÚº¯ÊýÏê½â,SQLServer,ʱ¼äÈÕÆÚ,
1.      µ±Ç°ÏµÍ³ÈÕÆÚ¡¢Ê±¼ä
        select getdate()
2. dateadd      ÔÚÏòÖ¸¶¨ÈÕÆÚ¼ÓÉÏÒ»¶Îʱ¼äµÄ»ù´¡ÉÏ£¬·µ»ØÐ嵀 datetime Öµ
       À ......

SQLServerºÍOracleµÄ³£Óú¯Êý¶Ô±È

SQLServerºÍOracleµÄ³£Óú¯Êý¶Ô±È
 
1.¾ø¶ÔÖµ
S:select abs(-1) value
O:select abs(-1) value from dual
 
2.È¡Õû(´ó)
S:select ceiling(-1.001) value
O:select ceil(-1.001) value from dual
 
3.È¡Õû£¨Ð¡£©
S:select floor(-1.001) value
O:select floor(-1.001) value from dual ......

SqlServerÆô¶¯²ÎÊý

SqlServerÆô¶¯²ÎÊý
1.Sqlservr.exeÔËÐвÎÊý¡£
SqlServerµÄÆô¶¯¿ÉÒÔΪWindows·þÎñ·½Ê½£¨Ä¬ÈÏ£©£¬Ò²¿ÉÒÔÒÔÓ¦ÓóÌÐò·½Ê½Æô¶¯¡£ÏÂÃæ½éÉÜsqlservr.exeÒÔÓ¦ÓóÌÐò·½Ê½Æô¶¯Ê±µÄ²ÎÊýÎÊÌâ¡£
sqlservrÓ¦ÓóÌÐòÓ÷¨£º
sqlservr[-sinstance_name][-c][-dmaster_path][-f]
[-eerror_log_path][-lmaster_log_path][-m]
[-n][-Ttrace ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ