1. Trang chủ
  2. » Công Nghệ Thông Tin

Tài liệu MASTERING SQL SERVER 2000- P23 pdf

50 325 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 50
Dung lượng 0,95 MB

Nội dung

APPENDIX A • TRANSACT-SQL REFERENCE 1120 T hroughout the book, you’ve seen examples of Transact-SQL (T-SQL) state- ments. Nearly every SQL Server operation can be performed using Transact- SQL from a graphical interface such as Query Analyzer or even from the command line using OSQL. This includes operations such as setting up jobs and alerts for which we demonstrated only the Enterprise Manager steps. In this appendix, we’ve presented all of the SQL statements that we discussed explicitly in this book. For each statement, we include the entire syntax and a cross- reference to the chapter where that statement is discussed in more depth. Creating a Database CREATE DATABASE statement (Chapter 10): CREATE DATABASE database_name ON [PRIMARY] ( NAME=logical_file_name, FILENAME=’os_file_name’, SIZE=size (in MB or KB), MAXSIZE=maximum_size (in MB or KB) or UNLIMITED (fill all available space), FILEGROWTH=growth_increment (in MB or KB) ) LOG ON ( NAME=logical_file_name, FILENAME=’os_file_name’, SIZE=size (in MB or KB), MAXSIZE=maximum_size (in MB or KB) or UNLIMITED, FILEGROWTH=growth_increment (in MB or KB) ) [ FOR LOAD | FOR ATTACH ] Cursor Statements DECLARE CURSOR statement (Chapter 8): DECLARE cursor_name [INSENSITIVE][SCROLL] CURSOR FOR select_statement [FOR {READ ONLY | UPDATE [OF column_name [,…n]]}] 2627appA.qxd 8/22/00 12:33 PM Page 1120 Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. 1121 DECLARE cursor_name CURSOR [LOCAL | GLOBAL] [FORWARD_ONLY | SCROLL] [STATIC | KEYSET | DYNAMIC | FAST_FORWARD] [READ_ONLY | SCROLL_LOCKS | OPTIMISTIC] [TYPE_WARNING] FOR select_statement [FOR UPDATE [OF column_name [,…n]]] OPEN statement (Chapter 8): OPEN {{[GLOBAL] cursor_name} | cursor_variable_name} FETCH statement (Chapter 8): FETCH [[ NEXT | PRIOR | FIRST | LAST | ABSOLUTE {n | @n_variable} | RELATIVE {n | @n_variable} ] FROM ] {{[GLOBAL] cursor_name} | @cursor_variable_name} [INTO @variable_name [,…n]] CLOSE statement (Chapter 8): CLOSE {{[GLOBAL] cursor_name} | cursor_variable_name} DEALLOCATE statement (Chapter 8): DEALLOCATE {{[GLOBAL] cursor_name} | cursor_variable_name} Database Options ALTER DATABASE statement (Chapter 5): ALTER DATABASE database_name SET {SINGLE_USER | RESTRICTED_USER | MULTI_USER} | {OFFLINE | ONLINE} | {READ_ONLY | READ_WRITE} | CURSOR_CLOSE_ON_COMMIT {ON | OFF} | CURSOR_DEFAULT {LOCAL | GLOBAL} | AUTO_CLOSE ON | OFF } | DATABASE OPTIONS Transact-SQL Reference APP A 2627appA.qxd 8/22/00 12:33 PM Page 1121 Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. APPENDIX A • TRANSACT-SQL REFERENCE 1122 AUTO_CREATE_STATISTICS ON | OFF } | AUTO_SHRINK ON | OFF } | AUTO_UPDATE_STATISTICS ON | OFF } | ANSI_NULL_DEFAULT { ON | OFF } | ANSI_NULLS { ON | OFF } | ANSI_PADDING { ON | OFF } | ANSI_WARNINGS { ON | OFF } | ARITHABORT { ON | OFF } | CONCAT_NULL_YIELDS_NULL { ON | OFF } | NUMERIC_ROUNDABORT { ON | OFF } | QUOTED_IDENTIFIERS { ON | OFF } | RECURSIVE_TRIGGERS { ON | OFF } | RECOVERY { FULL | BULK_LOGGED | SIMPLE } | TORN_PAGE_DETECTION { ON | OFF } [,…n] sp_dbcmptlevel statement (Chapter 5): sp_dbcmptlevel [[@dbname=] ‘database_name’] [,[@new_cmptlevel=] version] sp_dboption statement (Chapter 5): sp_dboption [[@dbname=] ‘database_name’] [, [@optname=] ‘option_name’] [, [@optvalue=] ‘option_value’] Deleting Records DELETE statement (Chapter 7): DELETE [FROM] { table_name [WITH (table_hint […n]]) | view_name | OPENQUERY | OPENROWSET | OPENDATASOURCE } [FROM table_source] [WHERE search_conditions] [OPTION query_hints] TRUNCATE TABLE statement (Chapter 7): TRUNCATE TABLE table_name 2627appA.qxd 8/22/00 12:33 PM Page 1122 Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. 1123 Inserting Records INSERT statement (Chapter 7): INSERT [INTO] { table_name [WITH (table_hint […n])] | view_name | OPENQUERY | OPENROWSET | OPENDATASOURCE } { [(column_list)] { VALUES ( { DEFAULT | NULL | expression }[,…n] ) | derived_table | execute_statement } } | DEFAULT VALUES SELECT INTO statement (Chapter 7): SELECT select_list INTO new_table_name FROM table_source [WHERE condition] [GROUP BY expression] HAVING condition] [ORDER BY expression] Retrieving Records SELECT statement (Chapter 6): SELECT [ALL | DISTINCT] [{TOP integer | TOP integer PERCENT} [WITH TIES]] < select_list > [INTO new_table] [FROM {< table_source >} [,…n]] [WHERE search_condition ] RETRIEVING RECORDS Transact-SQL Reference APP A 2627appA.qxd 8/22/00 12:33 PM Page 1123 Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. APPENDIX A • TRANSACT-SQL REFERENCE 1124 [GROUP BY [ ALL ] group_by_expression [,…n] [WITH { CUBE | ROLLUP }] [HAVING search_condition] [ORDER BY { order_by_expression | column_position [ASC | DESC]] [OPTION ( < query_hint > [ ,…n ])] Rowsets CONTAINSTABLE statement (Chapter 8): CONTAINSTABLE (table_name, {column_name | *}, ‘<search_condition>’ [,top_n]) <search_condition>::= { <generation_term> | <prefix_term> | <proximity_term> | <simple_term> | <weighted_term> } | {(<search_condition>) {AND | AND NOT | OR} <search_condition> […n] } <generation_term> ::= FORMSOF(INFLECTIONAL, <simple_term> [,…n]) <prefix_term> ::= {“word*” | “phrase*”} <proximity_term> ::= {<simple_term> | <prefix_term> } {{NEAR | ~} {<simple_term> | <prefix_term>}} […n] <simple_term> ::= word | “phrase” <weighted_term> ::= 2627appA.qxd 8/22/00 12:33 PM Page 1124 Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. 1125 ISABOUT ( {{ <generation_term> | <prefix_term> | <proximity_term> | <simple_term> } [WEIGHT (weight_value)] } [,…n]) Transactions BEGIN TRANSACTION statement (Chapter 8): BEGIN TRANS[ACTION] [transaction_name | @name_variable] [WITH MARK [‘description’]] COMMIT TRANSACTION statement (Chapter 8): COMMIT TRANS[ACTION] [transaction_name | @name_variable] COMMIT [WORK] ROLLBACK TRANSACTION statement (Chapter 8): ROLLBACK TRANS[ACTION] [transaction_name | @name_variable | savepoint_name | @savepoint_variable] ROLLBACK [WORK] SAVE TRANSACTION statement (Chapter 8): SAVE TRANS[ACTION] {savepoint_name | @savepoint_variable} FREETEXTTABLE statement (Chapter 8): FREETEXTTABLE (table_name, {column_name | *}, ‘freetext’ [,top_n]) OPENQUERY statement (Chapter 8): OPENQUERY(linked_server, ‘query’) OPENROWSET statement (Chapter 8): OPENROWSET (‘provider_name’, TRANSACTIONS Transact-SQL Reference APP A 2627appA.qxd 8/22/00 12:33 PM Page 1125 Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. APPENDIX A • TRANSACT-SQL REFERENCE 1126 ‘datasource’;’user_id’;’password’, ‘query’) OPENDATASOURCE statement (Chapter 8): OPENDATASOURCE(provider_name, connection_string) Updating Records UPDATE statement (Chapter 7): UPDATE { table_name [WITH (table_hint […n])] | view_name | OPENQUERY | OPENROWSET | OPENDATASOURCE } SET { column_name = {expression | DEFAULT | NULL} | @variable = expression | @variable = column = expression } [,…n] { [FROM {table_source} [,…n]] [WHERE search_condition] } [OPTION (query_hint [,…n])] UPDATETEXT statement (Chapter 7): UPDATETEXT {table_name.dest_column_name dest_text_ptr} { NULL | insert_offset } { NULL | delete_length } [WITH LOG] [ inserted_data | {table_name.source_column_pointer source_text_ptr} ] WRITETEXT statement (Chapter 7): WRITETEXT {table.column text_ptr} [WITH LOG] {data} 2627appA.qxd 8/22/00 12:33 PM Page 1126 Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. 1127 User-Defined Functions CREATE FUNCTION statement (Chapter 5): CREATE FUNCTION [owner_name].function_name ( [{@parameter_name data_type [=default_value]} [,…n]] ) RETURNS data_type [AS] {BEGIN function_body END} USER-DEFINED FUNCTIONS Transact-SQL Reference APP A 2627appA.qxd 8/22/00 12:33 PM Page 1127 Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. This page intentionally left blank Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. APPENDIX B Installing Microsoft SQL Server 2000 FEATURING: The Prerequisites 1130 The Setup Wizard 1131 The Client Software 1142 Unattended Setup 1142 Upgrading from a Previous Version 1143 Installing SQL Server Yourself 1150 Installing a Second Instance 1151 The Desktop Database Engine 1153 Troubleshooting Installation 1153 Service Packs 1154 2627appB.qxd 8/22/00 12:37 PM Page 1129 Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. [...]... connecting to SQL Server, such as Query Analyzer and Enterprise Manager Server and Client Tools: This will install the client tools as well as the SQL Server services This option is what actually turns your machine into a SQL Server Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark 2627appB.qxd 1134 8/22/00 12:37 PM Page 1134 APPENDIX B • INSTALLING MICROSOFT SQL SERVER 2000... Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark Installing Microsoft SQL Server 2000 2627appB.qxd 2627appB.qxd 1150 8/22/00 12:37 PM Page 1150 APPENDIX B • INSTALLING MICROSOFT SQL SERVER 2000 Installing SQL Server Yourself Now you are ready to install SQL Server 2000 on your own machine To do this, use the following steps: 1 Create a user account named SQLService and make... the Start menu, in the SQL Server 2000 group, click Enterprise Manager 2 Expand Microsoft SQL Servers by clicking the + icon next to it 3 Expand the SQL Servers group 4 You should now see two copies of your server: the default installation and Servername\Second Expand the Servername\Second installation If this step works, you have successfully installed two instances of SQL Server 2000 The Desktop... on, you’ll get to put this knowledge to use by installing SQL Server on your own machine Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark APP B Installing Microsoft SQL Server 2000 Component 2627appB.qxd 1132 8/22/00 12:37 PM Page 1132 APPENDIX B • INSTALLING MICROSOFT SQL SERVER 2000 NOTE There are two editions of SQL Server 2000: Standard and Enterprise Enterprise is tuned... control Unicode character storage If you need to replicate with older versions of SQL Server or will be switching between SQL Server 2000 and older versions, you should use SQL Collation If you are installing SQL Server 2000 on a machine with an older version of SQL Server installed, the setup program will detect the necessary SQL Collation for you; otherwise you will need to select the proper collation... running Here is a list of other things you can do to double-check the install: APP B 2 Expand Microsoft SQL Servers by clicking the + icon next to it 3 Expand the SQL Servers group 4 Expand your server; if this step works, SQL Server was successfully installed Installing a Second Instance Because SQL Server 2000 has the miraculous capability of running multiple instances of itself on the same machine,... Installation of SQL Server and click Next 6 Enter the proper information on the User Information screen and click Next Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark Installing Microsoft SQL Server 2000 1 On the Start menu, in the SQL Server 2000 group, click Enterprise Manager 2627appB.qxd 1152 8/22/00 12:37 PM Page 1152 APPENDIX B • INSTALLING MICROSOFT SQL SERVER 2000 7 Click... the setup of SQL Server Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark 2627appB.qxd 8/22/00 12:37 PM Page 1153 TROUBLESHOOTING INSTALLATION 1153 You can now test the second instance of SQL Server You can do a few things to test the installation; first, check your system tray for an icon that looks like a little server with a green arrow—this means that the MSSQLServer service... with other SQL Servers over the network Allows you to control the service permissions without allowing network access Global User None; slightly more difficult to configure than the other two Allows you to communicate fully with other network machines, including SQL Servers and e-mail servers Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark Installing Microsoft SQL Server 2000... have decided to leave your older version of SQL Server in place so that you may switch back in case of a problem, you will need to run the Upgrade Wizard at a later time In the next series of steps, you are going to upgrade a SQL Server 6.5 database by using the Upgrade Wizard: 1 Go to the SQL Server Switch group under Programs on the Start menu and select SQL Server Upgrade Wizard A welcome screen comes . ver- sions of SQL Server or will be switching between SQL Server 2000 and older versions, you should use SQL Collation. If you are installing SQL Server 2000. accounts, one for the MSSQLServer service and one for the SQLServerAgent service. A very good reason to do this is that only the SQLServerAgent service really

Ngày đăng: 26/01/2014, 08:20