• No results found

SQL Server Questions

N/A
N/A
Protected

Academic year: 2021

Share "SQL Server Questions"

Copied!
223
0
0

Loading.... (view fulltext now)

Full text

(1)c   

(2)   p   

(3)                p

(4)   p        !  " #     p   

(5)    " $ R. %&&'!  

(6) ()% * . R R R. %&&+!  

(7) ,-.    &+ %&&,!  

(8) ,+.   /  %&&&!  

(9) 0-.   " 1. R R R R R. %&&&!  

(10) 0-2 34.   4  )---!  

(11) )---')! .   " "

(12)  5- )--'!  

(13) )---,(! .      )--+!  

(14) )--+.   67

(15)  &- )--+!  

(16) )--+81 8  .    

(17)  . R R. Œ      

(18)    p   

(19) )--+81 8   "  

(20)  " p   

(21) )--+         

(22) )--+.""   p    

(23) )--+81 8  $ %9" p   

(24) )--+81 8      )9" :    "    .  7  1"  ; 8<48<8!+'+p;   " :   1" '

(25) "    =$>   " "    ." "     $ Name: SQLEXPR.EXE. escription: Microsoft SQL 2005 Server Express Edition Location: C:\temp Size: 56,105,688 bytes *ersion: 9.0.1399.6 c   

(26)    "    #   

(27) "   

(28) )--+81 8  $ Processor 32-bit Processor of 600-megahertz (MHz) or faster. R R R R R R R R R R R R R R R R R R R R R R R R R. Ñperating System Windows XP with Service Pack 2 or later Windows 2000 Professional with SP4 Windows 2000 Server with Service Pack 4 or later Windows Server 2003 Standard, or Enterprise SP1 Windows Server 2003 Web Edition SP1 Windows Small Business Server 2003 with SP1 *ista Home Basic and above ‰ramework .NET ‰ramework 2.0.

(29) R R R R R R R. R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R. R. Memory 512 megabytes (MB) or more recommended Hard isk Approximately 425 MB of available hard-disk space c   !"   #$% &# !  "     

(30) )--+81 8  .   p   

(31)  )--+  1 ""    $; " p * :  7)-     4        ; 6    "  .   *8 :  7)-        "  1     *8 :  7)- Œ      #$"% &' # *8 :  7?  )-  #   p      7   

(32) )--+      *8 :  7?  )-.""  $ %9" p *8 :  7?  )-     4 7  15,   )= 7"  

(33) "     1 1 $>  ' 7    "        "$ Name: dotnetfx.exe Location: C:\temp Size: 23,510,720 bytes *ersion: 2.0.50727.42 (=  8  81   +  7"     $$> > 1 1  " p *8 :  7)-   ":"     ""     c  #() (  #$"% &$*$ 4 

(34)  1         

(35)    " *8 :  7)-6      .         "  #  *8 :  7)- 

(36)  1       $ CPU usage: 00% Memory usage: 2,704K Launching method: System Service. irectory: C:\WIN ÑWS\Microsoft.NET\‰ramework\v2.0.50727\ ‰ile name: mscorsvw.exe. escription: .NET Runtime Ñptimization Service Size: 66,240 bytes. ate: ‰riday, September 23, 2005, 7:28:56 AM *ersion: 2.0.50727.42 Company name: Microsoft System essential: No *irus/Spyware/Adware: No Œ  

(37)    2 "

(38)     

(39) )--+81 8  .""      $ %  7 8<48<8 "   " )= 7* 1 "    7   "      '"  7 ."    " 7  #     ( " "     "       +2" 3"    p  . 7"   p 1 p   3"       

(40) 3"    3  ;:6  ; " ;  "     $;  ,=    ""      .

(41) R R R R R R R R R R R R R R R R R R R R R R R R R. R R R R R R R R R R R R R. 0"       .        $ @4 @ p   

(42) )--+@=     Œ   &  

(43)       3      

(44) )--,81 8  .      #    7    "    .  7p   6"      # 

(45)  1   "   $ sqlservr.exe 00 1,316 K   # 

(46)  1   7" ;84 ;.  

(47)       # 

(48)  1  "   .7"   

(49)    c #() (

(50)  +

(51) ,)- . 4 # 

(52)  1  " p   

(53)   

(54)       " p    

(55) )--+81   

(56)  1       $ CPU usage: 00% Memory usage: 1,316K Launching method: System Service. irectory: C:\Program ‰iles\Microsoft SQL Server\MSSQL.1 \MSSQL\Binn ‰ile name: sqlservr.exe. escription: SQL Server Windows NT Size: 28,768,528 bytes. ate: ‰riday, Ñctober 14, 2005, 3:51:46 AM *ersion: 2005.90.1399.0 Company name: Microsoft System essential: No *irus/Spyware/Adware: No Œ      

(57)      p   

(58) p     81 p8   . !!  "            

(59) )--+81 8     

(60) )--+81  8   "3

(61)   

(62)         ."   $ %9  

(63) p     81 "    )9" ;:    "  ;   '= 7"   1;  

(64) )--+Ap88 !'5+p;3

(65)   $>    ( 7    "        "$ Name: SQLServer2005_SSMSEE.msi Location: C:\temp Size: 40,364,032 bytes +  7   "   ":"     ""       ,"       .        $ @4 @ p   

(66) )--+@  

(67) p     81  Œ   

(68)      

(69)   2 "

(70)   

(71) )--+81        "  .       

(72) p     81 "  

(73) $ = 7 @4 @p   

(74) )--+@  

(75) p     81   "  

(76) p     81  " ;=  

(77) ;1" "  

(78) *   "    

(79)   ; 2=3 /2 > 8<48;B"     ;  

(80) 3"    ; " .

(81) 3"    8   ; ; "   . ;:6  ; " 4 . R R R R R R R R. R R R R R R.  = 7" = ." "   

(82) p     81     Œ  

(83)  

(84)      % "    

(85) p     81 "    

(86) )--+ 81  )= 7" ;*   ; "    8 "       "  #  $ SELECT 'Welcome to ‰ Icenter.com SQL Server!' '= 7" 81   "    6" "   "   $ Welcome to ‰ Icenter.com SQL Server!  "    7"  " #      $.  Œ    

(87)  / &0 %9"   

(88) )--+72      )= 7"  ." :   1"

(89) "    $>  '  7"     $$> ># 

(90) )C+A2 A: )--0  "       ":"     ""      (" "       6      "   $ @4 @ p   

(91) )--+@       Œ  

(92)  / &0   .

(93) R. R R R R. R R. R. R R. R.   

(94) )--+72          

(95) "             "

(96)          

(97) )--+72   7  ."   $ %= 7 @4 @p   

(98) )--+@      @  @  

(99)    "   

(100) )--+72   " )= 7"  D 1;  

(101) )--+   " =  ; '= 7"  D 1;  

(102)    ; (= 7; %$  *

(103)      

(104) p     ; " 7  " .  Œ  "(

(105)   1    !         "          /       

(106)  "   

(107) )--+72   "   

(108) )--+  @    8    @     !         "    

(109) )--+72    "       "          "       

(110)                   "       ! ." p      "     "           "    !               !   "     "          .        "  1           Œ  1 !2-3"43"3/3 ! "  "    # 7       E  "   !      "  ""       .      "     .  "    "  "    "      "          ! .      "   "   

(111)   "       "    "      

(112) p     81 . 7     !    ." =83 83 338   "   #       $"   "     =83 83 338 "        ..

(113) R R R R. R. R R. R. R. R R. R. R R R R. R R R R R R. " "  7  "   "       "  1  =83 8 3 338 ""       .  

(114)    

(115)   "        "   

(116)  "    1     " 1!   8  .  1  "   $ CREATE ATABASE Test ata rÑ F "     " =83 83 338. "  :% " =83 8 3 338    

(117) )--+72  " 6  "  " #   "    1=83 83 338 " "    "      "     8 . :+ 1  "                  "        .  

(118)  7  "      .     " "        "    " 7 

(119)   .           G "              Œ  1 !2-3""3/ ! "  "    # 7       E  "   !      "  ""       .      "     .  "    "  "    "      "          ! .      "   "   

(120)   "       "    "      

(121) p     81       .

(122)     "   . "        "  "             " " 

(123)        "  p  "

(124)    7 .    "   3  7     #  "     8     "    "    7 

(125)         "    :       7     ".        !  * $ "     8            

(126) !    

(127) "      8           

(128) .E     "

(129) "      : 1  .     2               283 3 "     8       !    

(130) ."            "     . "              "    "  . 1  " F8 "  "       1"        2"   .   "    "             "         F       "   "  ."        "       6"  E  "           

(131)      "41!   8  .    1  "   "    "         USE Test ata rÑ " 1!   8  .   1  "             4 "  "       4.4*  . 4  . 4    " 4 "   7 "    .

(132) " )+. .  1      2" 4   4      "

(133)   "      "   "               "   " "   "     E " "           . "   "         CREATE TABLE dbo.Products (ProductI int PRIMAR KE NÑT NULL, ProductName varchar(25) NÑT NULL, Price money NULL, Product escription text NULL) rÑ.

(134) R R. R. Œ   1 !$ -"!!5)43"! "  " "   # 7       E  "   !      "  ""       .      "     .  "    "  "    "      "          ! .      "   "   

(135)   "       "    "      

(136) p     81  *" "

(137)   " 4  .        "     " *8    3 "       . "  "     F43 8   6  " /88  " F43 8     "        "       "    . 4 4*   4   4    %. = . +-.  

(138)  '%0 : " . 0+ '--- R. R R R R R R. R R R R R. R R R R R. R R R R R. %)(5 7 " .   .  ' 7  +). "     . "    1 $*8 .    . .?3 F8. "   " 

(139)        " ""         " "       "  1     "   "   ."          

(140)   "   1 "  1!81  "         " 4   "     " 

(141)  7 "  "    1 -- Standard syntax INSERT dbo.Products (ProductI , ProductName, Price, Product escription) *ALUES (1, 'Clamp', 12.48, 'Workbench clamp') rÑ "     "" "  "   " ""        

(142)   " "    " 4 4*   ""       "    " 

(143)    -- Changing the order of the columns INSERT dbo.Products (ProductName, ProductI , Price, Product escription) *ALUES ('Screwdriver', 50, 3.17, '‰lat head') rÑ "        " "   "     .  " 

(144)       "    "  1           " "  "    *F.     " 4      "   "   7 -- Skipping the column list, but keeping the values in order INSERT dbo.Products *ALUES (75, 'Tire Bar', NULL, 'Tool for changing tires.') rÑ " "               "         "     " 4    

(145)   

(146)     

(147)  ." 4      

(148)     "        -- ropping the optional dbo and dropping the Product escription column INSERT Products (ProductI , ProductName, Price) *ALUES (3000, '3mm Bracket', .52) rÑ "   1!    1  "  F43 8   "   " 4*  "   

(149) .: /  

(150) .

(151) R R R R R R. R. R R R R R R. R R R R R R R R R R R R R R R R. R R R R R R R. UP ATE dbo.Products SET ProductName = '‰lat Head Screwdriver' WHERE ProductI = 50 rÑ Œ  1 !  2"! "  " "  # 7       E  "   !      "  ""       .      "     .  "    "  "    "      "          ! .      "   "   

(152)   "       "    "      

(153) p     81  F " 8 8=     "        " 8 8=      "      !    . "     

(154)    "  1:"  .  7 "

(155)   

(156)   "  1!    1  "      "    "  4   -- The basic syntax for reading data from a single table SELECT ProductI , ProductName, Price, Product escription ‰RÑM dbo.Products rÑ 6      7   "  "    "      " #  6"

(157)  "       " "       "    .

(158)       "      -- Returns all columns in the table -- oes not use the optional schema, dbo SELECT * ‰RÑM Products rÑ 6  "    "      "   " "      -- Returns only two of the columns from the table SELECT ProductName, Price ‰RÑM dbo.Products rÑ F  /88    " "     "   -- Returns only two of the records in the table SELECT ProductI , ProductName, Price, Product escription ‰RÑM dbo.Products WHERE ProductI < 60 rÑ 6 7 "" 

(159)   "  "      "   1      "       " 4  =" "

(160)  "   "    "

(161)     

(162)    " 37  -- Returns ProductName and the Price including a 7% tax -- Provides the name CustomerPays for the calculated column SELECT ProductName, Price * 1.07 AS CustomerPays ‰RÑM dbo.Products rÑ Œ     1  !2-3" 0*$! "  "    # 7             "   !    9            

(163) 

(164) "  : .      "   "   "   

(165)     8   "    "      "        3  . "          E  "  ""  "  . ""   .

(166) R. R. R. R R R R. R R R R R. R R. R. R R R R R R R R R.

(167)       " E  "    "       

(168) p     81    "     8  .  #     "      "  B             ."       

(169)   "  1    

(170) " 

(171)   "  3"       .     "

(172)     

(173) :"  .   "

(174)   

(175)    H"   .       3"       " .        "    "       

(176)  "       <4 4    " c  != 7 . 7. " 2 1.  I I> ')>J. "  72C " =  p      F   . 1   F  9. "! 7F . "  7*  F  " F   1 p  " 4  =  1.   . "  7=           "  !   8    

(177) p     .   1  "       A   ""    :2p *2    "    "    "   "    8:3F A3 338   p "        . "          "      "      "                !     CREATE LÑrIN [computer_name\Mary] ‰RÑM WIN ÑWS WITH E‰AULT_ ATABASE = [Test ata]; rÑ "  " G     p . "     .  "       

(178) "    "       

(179) )--+"  .   "   "   " p    Œ   1 !2-3"5 -! "  "    # 7              "   !    9            

(180) 

(181) "  : .      "   "   "   

(182)     8   "    "      "        3  . "          E  "  ""  "  . ""   

(183)       " E  "    "       

(184) p     81  p "   "      

(185) )--+. "

(186)      "     "  

(187) "

(188)   "             " G "          p   . ""        . "  " =83 8F8     "      p  " 1!    1  "          A   ""     p   "         USE [Test ata]; rÑ CREATE USER [Mary] ‰ÑR LÑrIN [computer_name\Mary]; rÑ *.p "   "  

(189) )--+ "        .

(190) R R. R. R. R. R R R R R R R R R R R. R R R R R R R R R R R R. R. Œ     !2-3"'c6)-0245-!  "  " "   # 7             "   !    9            

(191) 

(192) "  : .      "   "   "   

(193)     8   "    "      "        3  . "          E  "  ""  "  . ""   

(194)       " E  "    "       

(195) p     81  *" p    "        .          E ."  

(196)      . "  p   " 3

(197)     8 8=    .           !    "  1     " ?   #   7                  1" 

(198)     "

(199) "             " "  ." : / 8                  

(200)    "      :"  1  .  =83 8?8   

(201) "   "   " 4   " .  =83 842=8F8       "            " "  " "         

(202)   " !81  "        

(203)   

(204) "  1         .  "      "   CREATE *IEW vw_Names AS SELECT ProductName, Price ‰RÑM Products; rÑ " !?     E 7   F  8 8=       

(205)  SELECT * ‰RÑM vw_Names; rÑ "   ! "              A*  .          K? 4       "      "    4 "      ""      "   "  "       

(206) " %-"       " ."    1   8 8=    " 

(207) .  "        " /88    "   "  " "      

(208)   CREATE PRÑCE URE pr_Names @*arPrice money AS BErIN -- The print statement returns text to the user PRINT 'Products less than ' + CAST(@*arPrice AS varchar(10)); -- A second statement starts here SELECT ProductName, Price ‰RÑM vw_Names WHERE Price < @varPrice; EN. rÑ "   !  "    .   1  "       "   " "   "     " 4     % "   "   " %---.

(209) R R R R. R. R R R R R. R. R. R R. R R R R R R R R R R R R R R R R R R R. EXECUTE pr_Names 10.00; rÑ Œ     !*-3$",25"! "  " "  # 7              "   !    9            

(210) 

(211) "  : .      "   "   "   

(212)     8   "    "      "        3  . "          E  "  ""  "  . ""   

(213)       " E  "    "       

(214) p     81  3     .  1  " 8 8= " 4   " 

(215) A*  

(216) .  1  " A*    H"

(217) .p    p "        . " 93*     ) "!81  "     

(218) p " 8<8=F 8   "  A*      rRANT EXECUTE ÑN pr_Names TÑ Mary; rÑ "    .p    " 4   "      p     1   8 8=      " 

(219) ."   1  93* 8 8= 2*

(220) A*   2p   

(221)       E .  " 8?2C8    * $"   ." 

(222) . "       "   "  .          1:    "      E  "    . 2 " ="  31 *-3$"6"

(223) 8<8=F 8    1      6 "

(224) 8 8= .*8 .F43 8. 8 8 8      "     "  93*       "    ."         Œ  1 17 !4-0)!  

(225)      E   

(226)  .E   "      /

(227) . "  . """  

(228)  

(229)   7 "    -    17!     E . 7     "       $ USE Test ata; rÑ F " 8?2C8    

(230)  1     p "    $ RE*ÑKE EXECUTE ÑN pr_Names ‰RÑM Mary; rÑ F " 24    

(231)    p   "        $. RÑP USER Mary; rÑ F " 24    

(232)    p   "      

(233)  )--+$. RÑP LÑrIN [\Mary]; rÑ F " 24    

(234) "    A*  $. RÑP PRÑC pr_Names; rÑ F " 24    

(235) " 

(236) 

(237) A*  $. RÑP *iew vw_Names; rÑ F " 8 8 8    

(238)  " 4  $.

(239) R R R R R R. R R R R. ELETE ‰RÑM Products; rÑ F " 24    

(240) " 4  $. RÑP Table Products; rÑ 6  

(241) "        "     "     H"   .  "  1 "     . "  " 24    

(242) "         $ USE MASTER; rÑ. RÑP ATABASE Test ata; rÑ. c 1 3          "           E $ R R R.  !      ? !           1 !   1   " . R.  4  !4       . R R. F !           2" E . R R. c   1 "              " ;=83 83 338;    " "  1$ CREATE ATABASE database_name : 1  ."    $ CREATE ATABASE ‰yiCenter ata rÑ 3       ;: =    ;"    "   

(243) 2 . : =    "   "  !   ""

(244)  "    E       "  

(245)  Œ   1 2     "   

(246) ."       7 "    "       " ;F8;    ""  1$ USE database_name "    1  "" ;: =    ; "      .       ;: =    ;$ USE ‰yiCenter ata rÑ Changed database context to '‰yiCenter ata'.. R R R R R. R R R R R R R R R R R R R. CREATE TABLE Links (Name N*ARCHAR(32)) rÑ SELECT name, type_desc, create_date ‰RÑM sys.tables rÑ.

(247) R R R R R R R R R R R R R. R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R. name type_desc create_date Links USER_TABLE 2007-05-19 23:05:43.700 Œ  1          ."

(248)      "      .       "" ;243 338;    ""  1$. RÑP ATABASE database_name : 1  . 1  "    $. RÑP ATABASE ‰yiCenter ata rÑ "     ;: =    ;   " 

(249)  "    "    

(250)    .         .    "    "           c        1         "    .        7 " $B=      ;: =    ;        B         .     "           "     ."          "       " "   1  $ CREATE ATABASE ‰yiCenter ata rÑ USE ‰yiCenter ata rÑ. RÑP ATABASE ‰yiCenter ata rÑ Msg 3702, Level 16, State 4, Server LÑCALHÑST\SQLEXPRESS Cannot drop database "‰yiCenter ata" because it is currently in use. USE master rÑ. RÑP ATABASE ‰yiCenter ata rÑ Œ   1  

(251)  B         "

(252)   .          "  

(253) # " ;    ;

(254)  " "   1  $ CREATE ATABASE ‰yiCenter ata rÑ SELECT name, database_id, create_date ‰RÑM sys.databases rÑ name database_id create_date master 1 2003-04-08 09:13:36.390 tempdb 2 2007-05-19 13:42:42.200 model 3 2003-04-08 09:13:36.390 msdb 4 2005-10-14 01:54:05.240 ‰yiCenter ata 5 2007-05-19 20:04:39.310 3  ."            "  #  .

(255) c 1    &          "  =83 83 338   ."  

(256)           " "  7           "     $ R R.     A  !  

(257)     4    :       A  A!  

(258)          :  .  "         . # " ;    A  ;

(259)  "  "   1  $ USE ‰yiCenter ata rÑ SELECT type_desc, physical_name, size ‰RÑM sys.database_files rÑ type_desc physical_name RÑWS. LÑr. size. c:\Program ‰iles\Microsoft SQL Server \MSSQL.1\MSSQL\ ATA\‰yiCenter ata.mdf c:\Program ‰iles\Microsoft SQL Server \MSSQL.1\MSSQL\ ATA\‰yiCenter ata_log.L ‰. 152. 63. 9

(260)  "     " 81 . Œ  1     B 7 "    "

(261) " =83 83 338   .   "  "         "     $ CREATE ATABASE database_name ÑN (NAME = logical_data_name, ‰ILENAME = physical_data_name, SIZE = x, MAXSIZE = y, ‰ILErRÑWTH = z) LÑr ÑN (NAME = logical_log_name, ‰ILENAME = physical_log_name, SIZE = x, MAXSIZE = y, ‰ILErRÑWTH = z) : 1  ."              "         " =$>    $ USE master rÑ. RÑP ATABASE ‰yiCenter ata rÑ CREATE ATABASE ‰yiCenter ata ÑN (NAME = ‰yiCenter ata, ‰ILENAME = 'C:\temp\‰yiCenter ata.mdf',.

(262) SIZE = 10MB, MAXSIZE = 50MB, ‰ILErRÑWTH = 5MB) LÑr ÑN (NAME = ‰yiCenterLog, ‰ILENAME = 'C:\temp\‰yiCenterLog.ldf', SIZE = 1MB, MAXSIZE = 5MB, ‰ILErRÑWTH = 1MB) rÑ SELECT type_desc, name, physical_name, size ‰RÑM sys.database_files rÑ type_desc name physical_name RÑWS ‰yiCenter ata C:\temp\‰yiCenter ata.mdf LÑr ‰yiCenterLog C:\temp\‰yiCenterLog.ldf. size 1280 128. Œ  1 B 7 "        . "    " ;3 83 338;     ""   1$ ALTER ATABASE database_name MÑ I‰ NAME = new_database_name "   1   """  "       ;: =    ; ;: =  =  ;$ ALTER ATABASE ‰yiCenter ata MÑ I‰ NAME = ‰yiCenterCom ata rÑ The database name '‰yiCenterCom ata' has been set. c       1            "    .        7 " $; "        1

(263) 7  "    ;           .     "     2"   .      " "   1  $ % "      

(264) p      $ USE ‰yiCenterCom ata rÑ )C "        " "      

(265) p     $ ALTER ATABASE ‰yiCenterCom ata MÑ I‰ NAME = ‰yiCenter ata rÑ Msg 5030, Level 16, State 2, Server LÑCALHÑST\SQLEXPRESS The database could not be exclusively locked to perform the operation. 2

(266) ."      7 " ;3 83 338;   .

(267) c 1 3              : 1  ."      2* *8.2:: *8. F48=  

(268)  "         .  "   A  "        

(269)  "       "        R. 2* *8!     

(270)      "        . """  "   

(271)  "

(272)    . R. 2:: *8!     

(273)   3         1                     7 : 1  ."        7      

(274)       7 "      " " 7    "  

(275) "    . R. 8 2*9!2    "          .               "      

(276)   . R. 8=2?8*9!       

(277)   "  

(278)         H"                "  

(279)  "  

(280)  ."           "      

(281)    8=2?8648**9!  

(282) "       !      

(283)  "         .                

(284)      "      

(285)   3     "    #    

(286) "    "  

(287)     . R. R. R. R R R R R R R R R R R R R R R R R R R. F48= !3 "              "         

(288)      

(289)  "      

(290)   3     "     #   

(291) "   8p898*=6!F " "  "       "  8p898*=6 "          !           "       7  83A2* 6.     .         "    1  

(292)   8p898*=6      "  : 1  .       7      " 8p898*=6   "   "       !  "     . Œ  1 0%% $  

(293)     "    ." 7 "        "  ;3 83 338;    ""   1$ ALTER ATABASE database_name SET щ‰LINE "    1    ;: =  =  ;  $ ALTER ATABASE ‰yiCenterCom ata SET щ‰LINE rÑ SELECT name, state_desc from sys.databases rÑ name state_desc master ÑNLINE tempdb ÑNLINE model ÑNLINE msdb ÑNLINE ‰yiCenterCom ata щ‰LINE USE ‰yiCenterCom ata rÑ Msg 942, Level 14, State 4, Line 1.

(294) R R R R. R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R. atabase '‰yiCenterCom ata' cannot be opened because it is offline. Œ   1    

(295)     "        .  " ;3 8 3 338;    "       .  7 "    "     "   

(296)   1  $ ALTER ATABASE ‰yiCenterCom ata SET ÑNLINE rÑ USE ‰yiCenterCom ata rÑ CREATE TABLE Links (Name N*ARCHAR(32)) rÑ ALTER ATABASE ‰yiCenterCom ata SET щ‰LINE rÑ *    

(297) "     "        $ 1. Run Windows Explorer 2. Create a new directory: c:\temp\data 3. rag and drop c:\temp\‰yiCenter ata.mdf to c:\temp\data 3. rag and drop c:\temp\‰yiCenterLog.mdf to c:\temp\data 9 7"     $ ALTER ATABASE ‰yiCenterCom ata MÑ I‰ ‰ILE (NAME = ‰yiCenter ata, ‰ILENAME = 'C:\temp\data\‰yiCenter ata.mdf') rÑ The file "‰yiCenter ata" has been modified in the system catalog. The new path will be used the next time the database is started. ALTER ATABASE ‰yiCenterCom ata MÑ I‰ ‰ILE (NAME = ‰yiCenterLog, ‰ILENAME = 'C:\temp\data\‰yiCenterLog.ldf') rÑ The file "‰yiCenterLog" has been modified in the system catalog. The new path will be used the next time the database is started. ALTER ATABASE ‰yiCenterCom ata SET ÑNLINE rÑ USE ‰yiCenterCom ata rÑ SELECT type_desc, name, physical_name, size ‰RÑM sys.database_files rÑ type_desc name physical_name RÑWS ‰yiCenter ata C:\temp\data\‰yiCenter ata.mdf. size 1280.

(298) R R R R R R R. LÑr. ‰yiCenterLog. C:\temp\data\‰yiCenterLog.ldf. 128. SELECT name, type_desc ‰RÑM sys.tables rÑ name type_desc Links USER_TABLE 3  " "      

(299)  . " ; 7;    "  . Œ  1 1-3480$ 9        

(300) "

(301)    $ R. 83A 8!  E      #      "  "   . R. 83A2* 6!  E      #  .     . 6  " ;3 83 338;"          " "    $ USE ‰yiCenterCom ata rÑ INSERT Links (Name) *ALUES ('dba.‰ Icenter.com') rÑ (1 rows affected) ALTER ATABASE ‰yiCentercom ata SET REA _ÑNL rÑ INSERT Links (Name) *ALUES ('dev.‰ Icenter.com') rÑ Msg 3906, Level 16, State 1, Server SQLEXPRESS, Line 1 ‰ailed to update database "‰yiCenterCom ata" because the database is read-only. SELECT * ‰RÑM Links rÑ Name dba.‰ Icenter.com ALTER ATABASE ‰yiCentercom ata SET REA _WRITE rÑ INSERT Links (Name) *ALUES ('dev.‰ Icenter.com') rÑ (1 rows affected) 3  " .             "        83A2* 6 .

(302) Œ  1 1 $* 85 -        

(303) "

(304) "     $ R pF AF8!3 " "

(305) "        "          "  "    R *9 8AF8!2          "     3"       7  R. 8 = 8AF8!2  " A  1             1  

(306)       "     .    "   . 6  " ;3 83 338;"           " "    $ USE ‰yiCenterCom ata rÑ ALTER ATABASE ‰yiCentercom ata SET SINrLE_USER rÑ *  

(307)  " "     $ USE ‰yiCenterCom ata rÑ Msg 924, Level 14, State 1, Line 1. atabase '‰yiCenterCom ata' is already open and can only have one user at a time. 9 7"      ! "     pF AF8$ ALTER ATABASE ‰yiCenterCom ata SET MULTI_USER rÑ. c 1          "   

(308)    "               "   

(309) "    "         1       

(310) )--+81 8   (     $ R.   ! "     

(311) !  

(312)    .     .          . R.  !3      !F       . R R. ! "  7E"  !F  7E     7  ! "       !F "  

(313)    " . c 1 3           E       "

(314) "    $ R          "    R. =  !    "  .   . R. 3  E  "

(315) "      E  7 . .  .  1 .     .

(316) : 1  .     3  "

(317)               7 .  . ..  . . c 44 +44     . 1                           E  "       "   "               $ R. =83 8 3 8!=      . R. 3 8 3 8!3  "       1    . R. 24 3 8!   1    . R R. Œ  1 !2-3""3/ !        .  " ;=83 8 3 8;    "     ""       ; ;$ CREATE TABLE tip (id INTErER PRIMAR KE , subject *ARCHAR(80) NÑT NULL, description *ARCHAR(256) NÑT NULL, create_date ATETIME NULL) rÑ "           ; ; "( "       Œ " *  3"1 !#1!'   "   "

(318) E  .  " ;  ; 

(319)         "       "   

(320)   1  $ SELECT name, type_desc, create_date ‰RÑM sys.tables rÑ name type_desc create_date tip USER_TABLE 2007-05-19 23:05:43.700 " "" "       "       Œ " *  2   !# !' "

(321)   1    .B   "   "     "   .   " ;; 

(322)         "                . E      " "   1   $ SELECT * ‰RÑM sys.columns c, sys.tables t WHERE c.object_id = t.object_id AN t.name = 'tip' rÑ object_id name column_id user_type_id max_length 2073058421 id 1 56 4 2073058421 subject 2 167 80 2073058421 description 3 167 256 2073058421 create_date 4 61 8 6  "     " 

(323)   "    "  #   " E  "    6 "  ;A;        " "  1  Œ " *  2   !8 !  )  "

(324)   1    .B   "   "     "   .   " ;A;       "       "    "  1  $. R R R R R R R R R R R R R R R. R R R R R R R R R R R. R R.

(325) R R R R R R R R R R. R R. R R R R R R R R R R R. sp_columns tip rÑ TABLE_ÑWNER TABLE_NAME CÑLUMN_TABLE T PE_NAME ... dbo tip id int ... dbo tip subject varchar ... dbo tip description varchar ... dbo tip create_date datetime ... " ;A;         ""        7  7  ""  Œ " *  2   !8 !  )  3"          " ;A" ;    ;A" ;  " E   $"      ."    ."    ." 9F."   7 .  1 .   ;A"  ;   

(326) p     .  "   "  "   $.  Œ " *2-3""3/    "1  7"  1       .    

(327) p               ;=83 8 3 8;  "   "" " $ %  

(328) p         

(329)  )2" 2E 81  ." E  $    @: =    @  @   '= 7 "   "  1 " (  ;    ;@;=83 8;@;*   8  ; "         $ USE [‰yiCenter ata] rÑ /****** Ñbject: Table [dbo].[tip] Script ate: 05/19/2007 21:34:19 ******/ SET ANSI_NULLS ÑN rÑ SET QUÑTE _I ENTI‰IER ÑN.

(330) R R R R R R R R R R R R R R R R R R R. R R R R R R R R R R R R R R R R R R R R R R R. R R R. rÑ SET ANSI_PA. INr ÑN rÑ CREATE TABLE [dbo].[tip]( [id] [int] NÑT NULL, [subject] [varchar](80) CÑLLATE SQL_Latin1_reneral_CP1_CI_AS NÑT NULL, [description] [varchar](256) CÑLLATE SQL_Latin1_reneral_CP1_CI_AS NÑT NULL, [create_date] [datetime] NULL, PRIMAR KE CLUSTERE ( [id] ASC )WITH (PA _IN EX = щ‰, IrNÑRE_ UP_KE = щ‰) ÑN [PRIMAR ] ) ÑN [PRIMAR ] rÑ SET ANSI_PA. INr щ‰ Œ  1 !  2"###$"0!. B "

(331)     "   .     7"       " .  " ;8 8= * 2;    "     

(332)   1  $ INSERT INTÑ tip *ALUES (1, 'Learn SQL', '*isit dev.fyicenter.com','2006-07-01') rÑ SELECT * INTÑ tipBackup ‰RÑM tip rÑ (1 rows affected) SELECT * ‰RÑM tipBackup rÑ id subject description 1 Learn SQL *isit dev.fyicenter.com. create_date 2006-07-01. sp_columns tipBackup rÑ TABLE_ÑWNER TABLE_NAME CÑLUMN_TABLE T PE_NAME ... dbo tipBackup id int ... dbo tipBackup subject varchar ... dbo tipBackup description varchar ... dbo tipBackup create_date datetime ... 3  ." ;8 8= * 2;          ;  7; "         " ; ;        ;  7; Œ " 3$2   "1 !3 "-"3/ ###344! "

(333)   1     " 1    .     "   .   " ;3 8 3 83;    "    "  1  $ ALTER TABLE tip A. author *ARCHAR(40) rÑ.

(334) R R R R R R R R R R R R R R R R. R R R R R R R R R R. R R R R R R R R R R R R R R R R R R. sp_columns tip rÑ TABLE_ÑWNER TABLE_NAME dbo tip dbo tip dbo tip dbo tip dbo tip. CÑLUMN_TABLE id subject description create_date author. T PE_NAME int varchar varchar datetime datetime. ... ... ... ... ... .... SELECT * ‰RÑM tip rÑ id subject description create_date author 1 Learn SQL *isit dev.fyicenter.com 2006-07-01 NULL "         ; ";" ; ;  *F. 

(335)       "   1     Œ " 4 2 "1 !3 "-"3/ ###4-0)20 5$! "

(336)   1        "   .       ";3 8 3 824=2 Fp*;   /           1  $ ALTER TABLE tip RÑP CÑLUMN create_date rÑ SELECT * ‰RÑM tip rÑ id subject description author 1 Learn SQL *isit dev.fyicenter.com NULL 3  ." ;  A  ;   Œ      !8!   "

(337)   1        "  "   .   " ;A   B=2 Fp*B;   ;A   ; "     =2 Fp*.3 338.*8<.F83 3 648. 2L8=  "   1    ""    $ USE master rÑ sp_rename 'tip.subject', 'title', 'CÑLUMN' rÑ Msg 15248, Level 11, State 1, Procedure sp_rename, Line 213 Either the parameter @objname is ambiguous or the claimed @objtype (CÑLUMN) is wrong. USE ‰yiCenter ata rÑ sp_rename 'tip.subject', 'title', 'CÑLUMN' rÑ Caution: Changing any part of an object name could break scripts and stored procedures. SELECT id, title, description, author ‰RÑM tip.

(338) R R R R R R. R R R R R R. R R R R R R R R R R R R R R R R R R R R R R R. R R R R R R. rÑ id title description author 1 Learn SQL *isit dev.fyicenter.com NULL 6    "      B: =    B "       Œ     

(339)           

(340) p     .        E  """ 2E 81   "   1   ""     $ %  

(341) p         

References

Related documents

Additional Tools Included SQL Server 2005 Express Edition SQL Server 2005 Express Edition SQL Server 2005 Developer Edition SQL Server 2005 Developer Edition; Microsoft Office

to look young for one’s years aparentar joven para la edad de uno.. to be getting on in years entrar

Post on particle physics by david tongs notes are intended to me and is qft lectures on particle physics forums instead of the need for various courses.. Assume any case, textbook for

• SQL Server Reporting Services • SQL Server Data Warehousing • SQL Server Database Backups • SQL Server Performance • SQL Server Replication • Entity Framework •

The configuration of Microsoft SQL Server takes a little time, for this application we used ‘Microsoft SQL Server Management Studio Express’ with SQL Server Configuration Manager

The database space analysis state monitoring rule “SQL Server Database Space Analysis” is in the Microsoft SQL Server\SQL Server 2005\State Monitoring and Service Discovery

• If you are installing a new instance of SQL Server and you have an existing SQL Server installation, or if you are installing SQL Server in a language different from the

Install Quest SQL Optimizer for SQL Server Upgrade Quest SQL Optimizer for SQL Server Uninstall Quest SQL Optimizer for SQL Server Register Quest SQL Optimizer for SQL Server..