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

ÀûÓÃͬÒå´Ê¼ò»¯SQL Server 2005¿ª·¢

Ò». ÒýÑÔ
¡¡¡¡Èç¹ûÄãÔø¾­Ê¹ÓÃSQL Server¿ª·¢¹ýÈκÎÈí¼þ£¬ÄÇôÄã¿Ï¶¨»áÏ°¹ßÓÚʹÓÃËIJ¿·Ö±êʶ·ûÀ´²Î¿¼Ò»¸ö¶ÔÏó£º
[[[server.][database].][schema_name].]object_name
¡¡¡¡ÕýÈçÉÏÃæµÄ·½À¨ºÅËùÏÔʾµÄ£¬¸ÃÓï·¨µÄ²»Í¬²¿·Ö¿ÉÒÔ±»ºöÂÔ£¬Ö»ÒªÄãÌṩ×ã¹»µÄ±í´ïÀ´ÎÞ¶þÒåµØ±êʶÄãµÄ¶ÔÏó¼´¿É¡£ÀýÈ磬ÏÂÃæËùÓÐÕâЩ±í´ï¶¼¿ÉÄܲο¼ÏàͬµÄ¶ÔÏó£º
Server1.AdventureWorks.Production.ProductCategory
AdventureWorks.Production.ProductCategory
AdventureWorks..ProductCategory
ProductCategory
¡¡¡¡ÔÚ´ó¶àÊýÇé¿öÏ£¬Äã¿ÉÒÔ½öʹÓÃÈý²¿·ÖÃû×Ö¶øºöÂÔ·þÎñÆ÷Ãû-³ý·ÇÄãÊÇÔÚ´¦ÀíÔÚÒ»¸öÁ¬½ÓµÄ·þÎñÆ÷ÉϵĶÔÏó¡£Ä¬ÈÏÇé¿öÏ£¬ËùÓжÔÏóµÄÉÏÏÂÎĶ¼ÊDZ¾µØÊý¾Ý¿â-ÄãµÄSQLÓï¾äÔÚÆäÖÐÖ´ÐС£µ«ÊÇ£¬ÓÐЩÇé¿öÏ£¬»òÕ߸üΪ׼ȷµØ˵£¬Äã±ØÐëʹÓÃÕâÕû¸öËIJ¿·ÖÃüÃû£¨»ò³Æ×÷Ò»ÖÖÈ«³ÆÏÞ¶¨Ãû£©¡£µ«ÊÇ£¬ÔÚSQL Server 2005ÖУ¬ÕâÖÖÇé¿öÓÐËù¸Ä±ä¡£
¡¡¡¡¶þ. ÊìϤͬÒå´Ê
¡¡¡¡SQL Server 2005ÒýÈëÁËÒ»¸öͬÒå´ÊµÄ¸ÅÄÕâÊÇÒ»¸öµ¥²¿·ÖµÄÃû×Ö£¬Ëü¿ÉÒÔÌæ»»ÔÚÐí¶àSQLÓï¾äÖеÄÒ»¸öÁ½¡¢Èý»òËIJ¿·ÖµÄÃû×Ö¡£Ê¹ÓÃͬÒå´Ê¿ÉÒÔÈÃÄã¼õÉÙÊäÈ룬¶øÇÒ»¹ÄÜÌṩһ¸ö³éÏó²ãÀ´ÎªÄã±£»¤µ×²ã¶ÔÏóµÄ¸Ä±ä¡£ÎªÁËÀí½âÆ乤×÷Ô­Àí£¬ÈÃÎÒÃÇÏÈ¿´Ò»Ï´´½¨Í¬Òå´ÊµÄÓï·¨¡£ÏÂÃæÊÇCREATE SYNONYMÓï¾äµÄÓï·¨£º
CREATE SYNONYM [schema_name.]synonym_name FOR object_name
¡¡¡¡ÔÚ´Ë£¬object_nameÊÇÒ»¸öSQL Server¶ÔÏó(È«³ÆÏÞ¶¨ÒѾ­×ãÒÔÄܹ»±êʶ³öÕâ¸ö¶ÔÏó)µÄÃû×Ö£¬¶øsynonym_nameÊÇÄãÏ븳¸øËüµÄÐÂÃû×Ö¡£Èç¹ûÄã²»ÏëΪͬÒå´ÊÖ¸¶¨Ò»ÖÖģʽ£¬ÄÇôSQL ServerʹÓõ±Ç°µÄÓû§µÄĬÈÏģʽ¡£µ±Äã´´½¨Í¬Òå´Êʱ£¬ÏàÓ¦µÄ¶ÔÏó²»ÐèÒª´æÔÚ£¬ÒòΪͬÒå´ÊÊdzٰ󶨵ģºµ±Äãʵ¼ÊÉÏʹÓÃͬÒå´Êʱ£¬SQL Server½ö½ö¼ì²é»ù¶ÔÏó¡£
¡¡¡¡ÀýÈ磬ÔÚAdventureWorksʾÀýÊý¾Ý¿âÖУ¬Äã¿ÉÒÔÒÔÏÂÁз½Ê½´´½¨Ò»¸öͬÒå´Ê£º
CREATE SYNONYM ProdCat
FOR AdventureWorks.Production.ProductCategory
¡¡¡¡Ö®ºó£¬Äã¿ÉÒÔ¼ÌÐøʹÓÃÔÚSQLÓï¾äÖеÄͬÒå´ÊÁË¡£ÀýÈ磺
SELECT * from ProdCat
¡¡¡¡Í¼1ÏÔʾ³öÏàÓ¦µÄ½á¹û£º
¡¡¡¡µ±ÄãʹÓÃÍêÒ»¸öͬÒå´Êºó£¬Äã¿ÉÒÔʹÓÃDROP SYNONYMÓï¾äÀ´È¥µôËü£¬Ëü¾ßÓÐÄãÆÚÍûµÄÓï·¨¸ñʽ£º
DROP SYNONYM [schema_name.]synonym_name
Èý. ¼¸µãϸ½Ú
¡¡¡¡µ±È»£¬¶ÔÓÚͬÒå´ÊµÄʹÓÃÉÏÒ²´æÔÚһЩÏÞÖÆ¡£¶ÔÓÚ³õѧÕßÀ´Ëµ£¬Äã²»ÄÜΪÈκζ«Î÷¶¼´´½¨Ò»¸öͬÒå´Ê¡£SQL Server 2005±ÈÒÔÇ°ÒýÈëÁ˸ü¶àµÄ¶ÔÏ󣬵«ÊÇͬÒå´Ê½öÏÞÓÚÓ¦ÓÃÓÚºËÐļ¯µÄ×îÓÐÓõÄһЩ¶ÔÏóÖУº


Ïà¹ØÎĵµ£º

SQL Server DATEDIFF() º¯Êý

¶¨ÒåºÍÓ÷¨
DATEDIFF() º¯Êý·µ»ØÁ½¸öÈÕÆÚÖ®¼äµÄÌìÊý¡£
Óï·¨
DATEDIFF(datepart,startdate,enddate)
startdate ºÍ enddate ²ÎÊýÊǺϷ¨µÄÈÕÆÚ±í´ïʽ¡£
datepart ²ÎÊý¿ÉÒÔÊÇÏÂÁеÄÖµ£º
datepart
Ëõд
Äê
yy, yyyy
¼¾¶È
qq, q
ÔÂ
mm, m
ÄêÖеÄÈÕ
dy, y
ÈÕ
dd, d
ÖÜ
wk, ww
ÐÇÆÚ
dw, w
Сʱ
h ......

SQL ServerÊý¾Ý¿â³£ÓõÄT SQLÃüÁî

1. ²é¿´Êý¾Ý¿âµÄ°æ±¾
select @@version
2.²é¿´Êý¾Ý¿âËùÔÚ»úÆ÷²Ù×÷ϵͳ²ÎÊý
exec master..xp_msver
3. ²é¿´Êý¾Ý¿âÆô¶¯µÄ²ÎÊý
sp_configure
4.²é¿´Êý¾Ý¿âÆô¶¯Ê±¼ä
select convert(varchar(30),login_time,120) from master..sysprocesses where spid=1
²é¿´Êý¾Ý¿â·þÎñÆ÷ÃûºÍʵÀýÃû
print ''Server Name.... ......

¸ßЧSQL²éѯ֮Ë÷Òý£¨I£©

´óÐÍϵͳµÄÉú²ú»·¾³£¬Ò»°ãÇé¿öÏ£¬ÎÒÃÇÆÀ¼ÛÒ»Ìõ²éѯÊÇ·ñÓÐЧÂÊ£¬¸ü¶àµÄÊǹØ×¢Âß¼­ IO( ÖÁÓÚΪʲô£¬»ØÍ·²¹Ò»Æª ) ¡£ÎÒÃdz£Ëµ£¬“Òª½¨±ëº·µÄË÷Òý”¡¢“Ҫд¸ßЧµÄ SQL ”£¬Æäʵ×îÖÕÄ¿µÄ¾ÍÊÇÔÚÏàͬ½á¹û¼¯Çé¿öÏ£¬¾¡¿ÉÄܼõÉÙÂß¼­ IO ¡£
1.1      where Ìõ¼þµÄÁÐÉ϶¼µÃÓÐͳ¼ÆÐÅ ......

SQL Server 2008 ϵı¸·ÝºÍÈÕÖ¾ÊÕËõ

ÔÚSQL Server 2008Ï£¬ÍøÉÏÒÔÇ°Á÷ÐеĽضÏÈÕÖ¾²¢ÊÕËõÎļþµÄ·½·¨²»ÊʺÏÁË£¬±¨Óï·¨´íÎó¡£
ͬʱÒòΪÎÒµÄÊý¾Ý¿âÈÕÖ¾Ôö³¤·Ç³£¿ì£¬´ó¸ÅÿÌìÔÚ1GÒÔÉÏ£¬Òò´Ë±ØÐë¶ÔÆä½øÐÐÊÕËõ¡£
¾­¹ýÔÚϵͳÉϵIJâÊÔ£¬¸Ð¾õÓÃSQL SERVERµÄά»¤¼Æ»®¸ü¿ÉÐУ¬ÏÖ½«²Ù×÷·½Ê½¼ò½éÈçÏ£º
×¢£ºÏÂÃæµÄ˵Ã÷ÖÐÒ²Ìáµ½ÁËʹÓòîÒ챸·Ý£¬ÒòΪÊý¾Ý¿âÎļþÔö³¤Ò²·Ç ......

C#ÏîÄ¿´ò°ü£¬²¢×Ô¶¯°²×°SQLÊý¾Ý¿â

ӦһλÍøÓѵÄÐèÇ󣬲¢ÐÞÕýÁËMVPÀîºé¸ù".NETƽ̨ÏÂWEBÓ¦ÓóÌÐòµÄ²¿Êð(°²×°Êý¾Ý¿âºÍ×Ô¶¯ÅäÖÃ)"ÖеÄosqlÓ÷¨´íÎó£¬ÒѲâÊÔͨ¹ý¡£
Ò»).´´½¨²¿ÊðÏîÄ¿
1. ÔÚ“Îļþ”²Ëµ¥ÉÏÖ¸Ïò“Ìí¼ÓÏîÄ¿”£¬È»ºóÑ¡Ôñ“н¨ÏîÄ¿”¡£
2. ÔÚ“Ìí¼ÓÐÂÏîÄ¿”¶Ô»°¿òÖУ¬Ñ¡Ôñ“ÏîÄ¿ÀàÐÍ”´°¸ñÖ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ