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

sql×ܽá

1.´´½¨Êý¾Ý¿â
    --exec xp_cmdshell 'mkdir d:\project'--µ÷ÓÃDOSÃüÁî´´½¨Îļþ¼Ð£¬Ê¹Óô˾äÐèÒªÆô¶¯SQLµÄÍâΧ¹¤¾ß
    if exists(select * from sysdatabases where name='Êý¾Ý¿âÃû')
     drop database Êý¾Ý¿âÃû
    set nocount on   --È¡ÏûÊÜÓ°ÏìÐÐÊý
    create database Êý¾Ý¿âÃû
    on
    (
     name='',
     filename='',--  .mdf .ldf
     size=10mb,
     maxsize=
     filename=    --Êý¾Ý¿â´óСÔö³¤Á¿
    )
    log on
    (
    )
    go
    use Êý¾Ý¿âÃû
--´´½¨µÇ¼Óû§
exec sp_addlogin 'Óû§Ãû','ÃÜÂë'
--È¥µôÊÜÓ°ÏìÐÐÊý
set nocount on
exec sp_grantdbaccess 'adminMaster','adminMaster'
--ÉèÖÃÓû§¶Ô±íµÄȨÏÞ
grant select,delete,update on bbstopic to ̞
2.´´½¨±í¼°Ìí¼ÓÔ¼Êø
    create table ±í
    (
    )
    alter table ±í add
    constraint Ô¼ÊøÃû primary key(ÁÐÃû)  --Ö÷¼üÔ¼Êø  identity
    constraint Ô¼ÊøÃû check(len(ÁÐÃû))  --checkÔ¼Êø
    constraint Ô¼ÊøÃû unique(ÁÐÃû) --ΨһԼÊø
    constraint Ô¼ÊøÃû default(ĬÈÏÄÚÈÝ) for ÁÐÃû
    constraint Ô¼ÊøÃû foreign key(Íâ¼üÃû)
    references Ö÷¼üÊý¾Ý¿âÃû(Ö÷¼üÃû)
    ck£ºcheckÔ¼Êø
    fk£ºÍâ¼üÔ¼Êø
    df£ºdefaultĬÈÏ
  ×¢£ºalter ¸Ä±ä, ¸ü¸Ä
    add ¼ÓÈ룬 Ôö¼Ó, Ìí¼Ó
    constraint Ç¿ÖÆ£¬ÏÞÖÆ, Ô¼Êø
    foreign key Íâ¼ü
    references ÒýÓÃ
          
3.sqlÖеĹؼü×Ö£º
    sysdatabases ×Ü¿â
    exists  ÅжÏÊÇ·ñ´æÔÚ


Ïà¹ØÎĵµ£º

¶Á¡¶SQL Server 2005¸ß¼¶¹ÜÀí¡·µÄһЩժҪ... Á¬ÔØ5

ÔÚT-SQLÖмàÊÓ½ø³Ì
DBA¸üÔ¸ÒâʹÓÃT-SQLµÄÔ­ÒòÊÇ¿ÉÒԱȓ»î¶¯¼àÊÓÆ÷”¸ü¼ÓÁé»îµØ»ñµÃÐÅÏ¢¡£
1.       sp_whoºÍsp_who2
´æ´¢¹ý³Ìsp_whoÒ²·µ»Øµ±Ç°Á¬½ÓÊý¾Ý¿âʵÀý£¬Ó듻¼àÊÓÆ÷”·Ç³£ÀàËÆ¡£È»¶ø£¬Óû§¿ÉÄÜ·¢ÏÖ×Ô¼º¸üÔ¸ÒâʹÓÃδ¹«¿ªËµÃ÷µÄsp_who2´æ´¢¹ý³Ì£¬ÒòΪËüÌṩ ......

EXCELÊý¾Ýµ¼ÈëSQL µÄÁíÀàÓ÷¨

×ö¿ª·¢¹ý³ÌÖУ¬¾­³£»áÓõ½½«ExcelÖÐÊý¾Ýµ¼³öµ½SQL ServerÖеÄÇé¿ö£¬Äã¿ÉÒÔÀûÓÃSQL SERVER ÖÐ×Ô´øµÄµ¼ÈëÊý¾ÝµÄ·½Ê½£¬µ«ÕâÖÖ·½Ê½£¬ÓÐʱ»á·¢ÏÖÊý¾Ýµ¼Èëºó£¬¿ÉÄÜΪ¿Õ£¬¿ÉÄÜ¿ªÍ·ÉÙ¸öÁ㣬´ËÖÖÇé¿ö¶à³öÏÖÓÚÊýÖµÐ͵ÄÁУ¬½ñÌìÔÚCSDNÉÏÏй䣬ż¶û·¢ÏÖÁËÒ»¸öÌû×Ó£¬½éÉܵÄÒÔÏÂÕâÖÖ·½·¨£¬±¾ÈËÇ¡ÆßÒò×î½ü¹«Ë¾×¼±¸ÉÏÊУ¬Éó¼Æ¾ÖÔÚ×öÉó¼Æ£¬¼¼ ......

SQLÊý¾Ý¿âÖ®¶þ

l  INNER JOIN
ÄÚÁ¬½ÓÊÇ×î³£¼ûµÄÒ»ÖÖÁ¬½Ó£¬ËüÒ³±»³ÆΪÆÕͨÁ¬½Ó£¬¶øE.FCodd×îÔç³Æ֮Ϊ×ÔÈ»Á¬½Ó¡£
ÏÂÃæÊÇANSI SQL£­92±ê×¼
select *  from    t_institution i
inner join t_teller t
on i.inst_no = t.inst_no  //˵Á½¸ö±íÖ®¼äµÄ¹ØϵÓÃON
where i.inst_no = "5801"
ÆäÖÐinner¿ÉÒÔÊ¡Â ......

SQLÊý¾Ý¿â

 CURSOR
==================================
l  SQL ÓαêCURSORµÄʹÓÃ
 
ʹÓÃÆðÀ´ºÜ¼òµ¥£¬Ïȶ¨Ò壬Ȼºó¸³¸öÖµ£¬´ò¿ª£¬Í¨¹ýWhile Loop Ò»¸öÒ»¸ö¶ÁÏÂÈ¥£¬×îºó¹Ø±Õ£¬ÊÍ·ÅÄÚ´æ¡£»ù±¾Ì×·ÈçÏ£º
DECLARE MyCursor cursor /* ÉùÃ÷Óα꣬ĬÈÏΪµ¥´¿ÏòÇ°µÄÓαꡣÈç¹ûÏëҪǰºóÌøÀ´ÌøÈ¥µÄ£¬Ð´³ÉScroll Cursor¼ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ