Sybase SQL Server™ Reference Manual  Volume 1: Commands, Functions,             and Topics                 Sybase SQL Serv...
Principal author: Server Publications GroupDocument ID: 32401-01-1100                         This publication pertains to...
PC DB-Net, PC Net Library, Powersoft Portfolio, Replication Agent, Replication                    Driver, Replication Serv...
Table of Contents              Audience. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....
Sybase SQL Server Release 11.0.x2. System and User-Defined Datatypes              Function . . . . . . . . . . . . . . . . ...
Sybase SQL Server Release 11.0.x                   create trigger . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...
Sybase SQL Server Release 11.0.x                readtext. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...
Sybase SQL Server Release 11.0.x                   Disk Mirroring . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...
Sybase SQL Server Release 11.0.xx
List of FiguresFigure 3-1:   File naming convention for database dumps ......................................................
Sybase SQL Server Release 11.0.xxii
List of TablesTable 1:      Syntax statement conventions ....................................................................
Sybase SQL Server Release 11.0.xTable 3-20:   Commands used to restore databases ............................................
Sybase SQL Server Release 11.0.xTable 5-15:    Roles required for SQL commands ..............................................
Sybase SQL Server Release 11.0.xxvi   List of Tables
Preface                 The SQL Server Reference Manual is a two-volume guide to Sybase                 SQL Server™ and th...
Related Documents                                            Sybase SQL Server Release 11.0.x                    • Chapter...
Sybase SQL Server Release 11.0.x                                        Conventions Used in This Manual                   ...
Conventions Used in This Manual                                       Sybase SQL Server Release 11.0.x                    ...
Sybase SQL Server Release 11.0.x                                     Conventions Used in This Manual                      ...
If You Need Help                                                    Sybase SQL Server Release 11.0.x                   Exp...
SQL ServerRoadmap
1   SQL Server Roadmap                                                 1.    This chapter helps you figure out how to use S...
Sybase SQL Server Release 11.0.x      Each task lists one or more related activities, plus the name of the      command or...
Sybase SQL Server Release 11.0.x                                                    Starting, Stopping, and Configuring SQ...
Starting, Stopping, and Configuring SQL Server                                          Sybase SQL Server Release 11.0.x  ...
Sybase SQL Server Release 11.0.x                                  Starting, Stopping, and Configuring SQL Server   Specify...
Starting, Stopping, and Configuring SQL Server                                      Sybase SQL Server Release 11.0.x      ...
Sybase SQL Server Release 11.0.x                                     Starting, Stopping, and Configuring SQL Server   Limi...
Starting, Stopping, and Configuring SQL Server                             Sybase SQL Server Release 11.0.x      Specify m...
Sybase SQL Server Release 11.0.x                                                          Creating and Maintaining Databas...
Creating and Maintaining Databases                                                      Sybase SQL Server Release 11.0.xSp...
Sybase SQL Server Release 11.0.x                                                         Creating and Maintaining Database...
Setting Database-Wide Options                                                          Sybase SQL Server Release 11.0.x   ...
Sybase SQL Server Release 11.0.x                                                             Setting Database-Wide Options...
Backing Up and Restoring Databases                                                              Sybase SQL Server Release ...
Sybase SQL Server Release 11.0.x                                                           Backing Up and Restoring Databa...
Backing Up and Restoring Databases                                                     Sybase SQL Server Release 11.0.xRes...
Sybase SQL Server Release 11.0.x                                               Managing Logins, Users, Groups, and Roles  ...
Managing Logins, Users, Groups, and Roles                                                        Sybase SQL Server Release...
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Sqlref
Upcoming SlideShare
Loading in...5
×

Sqlref

372

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
372
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Sqlref

  1. 1. Sybase SQL Server™ Reference Manual Volume 1: Commands, Functions, and Topics Sybase SQL Server Release 11.0.x Document ID: 32401-01-1100-03 Last Revised: January 24, 1996
  2. 2. Principal author: Server Publications GroupDocument ID: 32401-01-1100 This publication pertains to Sybase SQL Server Release 11.0.x of the Sybase database management software and to any subsequent release until otherwise indicated in new editions or technical notes. Information in this document is subject to change without notice. The software described herein is furnished under a license agreement, and it may be used or copied only in accordance with the terms of that agreement.Document Orders To order additional documents, U.S. and Canadian customers should call Customer Fulfillment at (800) 685-8225, fax (617) 229-9845. Customers in other countries with a U.S. license agreement may contact Customer Fulfillment via the above fax number. All other international customers should contact their Sybase subsidiary or local distributor. Upgrades are provided only at regularly scheduled software release dates. Copyright © 1989–1995 by Sybase, Inc. All rights reserved. No part of this publication may be reproduced, transmitted, or translated in any form or by any means, electronic, mechanical, manual, optical, or otherwise, without the prior written permission of Sybase, Inc.Sybase Trademarks APT-FORMS, Data Workbench, DBA Companion, Deft, GainExposure, Gain Momentum, Navigation Server, PowerBuilder, Powersoft, Replication Server, SA Companion, SQL Advantage, SQL Debug, SQL Monitor, SQL SMART, SQL Solutions, SQR, SYBASE, the Sybase logo, Transact-SQL, and VQL are registered trademarks of Sybase, Inc. Adaptable Windowing Environment, ADA Workbench, AnswerBase, Application Manager, APT-Build, APT-Edit, APT-Execute, APT-Library, APT-Translator, APT Workbench, Backup Server, Bit-Wise, Client-Library, Client/Server Architecture for the Online Enterprise, Client/Server for the Real World, Client Services, Configurator, Connection Manager, Database Analyzer, DBA Companion Application Manager, DBA Companion Resource Manager, DB-Library, Deft Analyst, Deft Designer, Deft Educational, Deft Professional, Deft Trial, Developers Workbench, DirectCONNECT, Easy SQR, Embedded SQL, EMS, Enterprise Builder, Enterprise Client/Server, Enterprise CONNECT, Enterprise Manager, Enterprise SQL Server Manager, Enterprise Work Architecture, Enterprise Work Designer, Enterprise Work Modeler, EWA, Gain Interplay, Gateway Manager, InfoMaker, Interactive Quality Accelerator, Intermedia Server, IQ Accelerator, Maintenance Express, MAP, MDI, MDI Access Server, MDI Database Gateway, MethodSet, Movedb, Navigation Server Manager, Net-Gateway, Net-Library, New Media Studio, OmniCONNECT, OmniSQL Access Module, OmniSQL Gateway, OmniSQL Server, OmniSQL Toolkit, Open Client, Open Client/Server, Open Client/Server Interfaces, Open Gateway, Open Server, Open Solutions, PC APT-Execute,
  3. 3. PC DB-Net, PC Net Library, Powersoft Portfolio, Replication Agent, Replication Driver, Replication Server Manager, Report-Execute, Report Workbench, Resource Manager, RW-DisplayLib, RW-Library, SAFE, SDF, Secure SQL Server, Secure SQL Toolset, SKILS, SQL Anywhere, SQL Code Checker, SQL Edit, SQL Edit/TPU, SQL Server, SQL Server/CFT, SQL Server/DBM, SQL Server Manager, SQL Server Monitor, SQL Station, SQL Toolset, SQR Developers Kit, SQR Execute, SQR Toolkit, SQR Workbench, Sybase Client/Server Interfaces, Sybase Gateways, Sybase Intermedia, Sybase Interplay, Sybase IQ, Sybase MPP, Sybase SQL Desktop, Sybase SQL Lifecycle, Sybase SQL Workgroup, Sybase Synergy Program, Sybase Virtual Server Architecture, Sybase User Workbench, SyBooks, System 10, System 11, the System XI logo, Tabular Data Stream, The Enterprise Client/Server Company, The Online Information Center, Warehouse WORKS, Watcom SQL, WebSights, WorkGroup SQL Server, XA-Library, and XA-Server are trademarks of Sybase, Inc. All other company and product names used herein may be trademarks or registered trademarks of their respective companies.Restricted Rights Use, duplication, or disclosure by the government is subject to the restrictions set forth in subparagraph (c)(1)(ii) of DFARS 52.227-7013 for the DOD and as set forth in FAR 52.227-19(a)-(d) for civilian agencies. Sybase, Inc., 6475 Christie Avenue, Emeryville, CA 94608.
  4. 4. Table of Contents Audience. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii How to Use This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii Related Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xviii Conventions Used in This Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix If You Need Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxii1. SQL Server Roadmap Starting, Stopping, and Configuring SQL Server. . . . . . . . . . . . . . . . . . . . . . . . . . 1-3 Creating and Maintaining Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9 Setting Database-Wide Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-12 Backing Up and Restoring Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-14 Managing Logins, Users, Groups, and Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-17 Defining and Using Datatypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-21 Creating and Maintaining Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-23 Auditing Server Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-31 Retrieving and Manipulating Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-33 Using Defaults and Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-38 Error Handling and Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-40 Using Global Variables to Get Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-42 Using System and Catalog Stored Procedures to Get Help . . . . . . . . . . . . . . . . . . 1-45 Managing Languages, Character Sets, and Sort Orders . . . . . . . . . . . . . . . . . . . . 1-49 Managing Database Devices, Segments, and Thresholds . . . . . . . . . . . . . . . . . . . 1-52 Setting Session-Wide Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-56 Using Stored Procedures and Triggers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-59 Managing Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-64 Creating and Using Views. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-66 SQL Server Reference Manual v
  5. 5. Sybase SQL Server Release 11.0.x2. System and User-Defined Datatypes Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1 Datatype Categories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1 Range and Storage Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2 Declaring the Datatype of a Column, Variable, or Parameter . . . . . . . . . . . . . . . . . . . 2-3 Datatype of Mixed-Mode Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5 Converting One Datatype to Another . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7 Standards and Compliance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9 Exact Numeric Datatypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10 Approximate Numeric Datatypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-14 Money Datatypes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-16 timestamp Datatype. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-18 Date/time Datatypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-20 Character Datatypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-25 Binary Datatypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-29 bit Datatype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-32 sysname Datatype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-33 text and image Datatypes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-34 User-Defined Datatypes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-403. Transact-SQL Commands alter database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6 alter table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10 begin...end . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-21 begin transaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-23 break . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-24 checkpoint. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-26 close . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-29 commit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-30 compute Clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-32 continue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-41 create database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-43 create default . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-48 create index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-51 create procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-59 create rule. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-70 create schema . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-74 create table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-76vi
  6. 6. Sybase SQL Server Release 11.0.x create trigger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-96 create view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-106 dbcc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-114 deallocate cursor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-120 declare . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-121 declare cursor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-123 delete . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-129 disk init . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-135 disk mirror . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-139 disk refit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-143 disk reinit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-144 disk remirror. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-146 disk unmirror . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-149 drop database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-152 drop default . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-154 drop index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-156 drop procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-158 drop rule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-160 drop table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-161 drop trigger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-164 drop view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-165 dump database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-166 dump transaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-179 execute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-194 fetch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-199 goto Label . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-202 grant. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-203 group by and having Clauses. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-214 if...else. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-227 insert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-230 kill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-239 load database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-242 load transaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-251 online database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-260 open . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-262 order by Clause. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-264 prepare transaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-268 print . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-269 raiserror . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-273 SQL Server Reference Manual vii
  7. 7. Sybase SQL Server Release 11.0.x readtext. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-279 reconfigure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-282 return . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-283 revoke . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-287 rollback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-294 rollback trigger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-296 save transaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-298 select. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-300 set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-313 setuser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-327 shutdown . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-329 truncate table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-332 union Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-334 update. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-338 update statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-346 use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-348 waitfor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-349 where Clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-352 while . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-359 writetext . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-362 4. Transact-SQL Functions Aggregate Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2 Datatype Conversion Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-9 Date Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-19 Mathematical Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-24 Row Aggregate Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-29 String Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-33 System Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-40 text and image Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-48 5. Transact-SQL Topics Auditing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3 Batch Queries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-6 Browse Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-8 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-10 Control-of-Flow Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-12 Cursors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-14viii
  8. 8. Sybase SQL Server Release 11.0.x Disk Mirroring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-27 Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-32 Identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-41 IDENTITY Columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-47 Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-61 Login Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-67 Null Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-70 Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-78 Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-81 Search Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-87 Subqueries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-92 Temporary Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-98 Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-102 Variables (Local and Global) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-122 Wildcard Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-129Index SQL Server Reference Manual ix
  9. 9. Sybase SQL Server Release 11.0.xx
  10. 10. List of FiguresFigure 3-1: File naming convention for database dumps ........................................................3-175Figure 3-2: Dumping several databases to the same volume..................................................3-177Figure 3-3: File naming convention for transaction log dumps..............................................3-190Figure 3-4: Dumping three transaction logs to a single volume.............................................3-192Figure 5-1: Nesting transaction statements................................................................................5-114 SQL Server Reference Manual xi
  11. 11. Sybase SQL Server Release 11.0.xxii
  12. 12. List of TablesTable 1: Syntax statement conventions .....................................................................................xixTable 2: Types of expressions used in syntax statements ..................................................... xxiiTable 2-1: Datatype categories .......................................................................................................2-1Table 2-2: Range and storage size for SQL Server system datatypes.......................................2-2Table 2-3: Precision and scale after arithmetic operations.........................................................2-7Table 2-4: Automatic conversion of fixed-length datatypes......................................................2-7Table 2-5: Integer datatypes .........................................................................................................2-10Table 2-6: Valid integer values .....................................................................................................2-10Table 2-7: Invalid integer values..................................................................................................2-11Table 2-8: Valid decimal values ...................................................................................................2-12Table 2-9: Invalid decimal values ................................................................................................2-12Table 2-10: Approximate numeric datatypes...............................................................................2-14Table 2-11: Money datatypes .........................................................................................................2-16Table 2-12: Transact-SQL datatypes for storing dates and times..............................................2-20Table 2-13: Date formats for datetime and smalldatetime datatypes ......................................2-21Table 2-14: Examples of datetime entries .....................................................................................2-23Table 2-15: Character datatypes.....................................................................................................2-25Table 2-16: Storage of text and image data ..................................................................................2-36Table 2-17: text and image global variables .................................................................................2-38Table 3-1: Transact-SQL commands..............................................................................................3-1Table 3-2: Information stored about referential integrity constraints ....................................3-17Table 3-3: Row aggregate functions used with the compute clause ......................................3-32Table 3-4: compute by clauses and detail rows .........................................................................3-38Table 3-5: Relationship between nulls and column defaults...................................................3-50Table 3-6: Duplicate row options.................................................................................................3-55Table 3-7: Index options................................................................................................................3-55Table 3-8: Rule binding precedence ............................................................................................3-71Table 3-9: Variable-length datatypes used to store nulls .........................................................3-85Table 3-10: Methods of integrity enforcement.............................................................................3-87Table 3-11: Information stored about cross-database referential integrity constraints .........3-92Table 3-12: Information stored about referential integrity constraints ..................................3-162Table 3-13: Commands used to back up databases and logs ..................................................3-171Table 3-14: Commands used to back up databases ..................................................................3-184Table 3-15: @@sqlstatus values ....................................................................................................3-200Table 3-16: Object access permissions.........................................................................................3-204Table 3-17: Command and object permissions..........................................................................3-207Table 3-18: Status values reported by sp_who ..........................................................................3-240Table 3-19: Commands used to restore databases from dumps .............................................3-245 SQL Server Reference Manual xiii
  13. 13. Sybase SQL Server Release 11.0.xTable 3-20: Commands used to restore databases ....................................................................3-254Table 3-21: Effect of sort order choices .......................................................................................3-266Table 3-22: SQL Server error return values................................................................................3-285Table 3-23: Object access permissions.........................................................................................3-288Table 3-24: Results of using aggregates with group by............................................................3-304Table 3-25: Permissions required for update and delete..........................................................3-314Table 3-26: Options to set for entry level SQL92 compliance..................................................3-325Table 3-27: Comparing datatypes in union operations ............................................................3-336Table 3-28: Comparison operators ..............................................................................................3-353Table 3-29: Arithmetic operators .................................................................................................3-354Table 3-30: Bitwise operators .......................................................................................................3-354Table 3-31: Wildcard characters...................................................................................................3-356Table 4-1: Transact-SQL functions.................................................................................................4-1Table 4-2: Aggregate functions ......................................................................................................4-2Table 4-3: Datatype conversion functions ....................................................................................4-9Table 4-4: Display formats for date/time information.............................................................4-10Table 4-5: Explicit, implicit, and unsupported datatype conversions ...................................4-12Table 4-6: Date functions ..............................................................................................................4-19Table 4-7: Date parts and their values ........................................................................................4-21Table 4-8: Arguments used in mathematical functions............................................................4-24Table 4-9: Mathematical functions ..............................................................................................4-25Table 4-10: Row aggregate functions ............................................................................................4-29Table 4-11: Arguments used in string functions .........................................................................4-33Table 4-12: Function names, arguments, and results..................................................................4-34Table 4-13: Arguments used in system functions .......................................................................4-40Table 4-14: System functions, arguments, and results ...............................................................4-41Table 4-15: text and image functions, arguments, and results ..................................................4-48Table 5-1: Transact-SQL topics.......................................................................................................5-1Table 5-2: System procedures used to manage auditing options .............................................5-4Table 5-3: Control-of-flow keywords ..........................................................................................5-12Table 5-4: @@sqlstatus values ......................................................................................................5-22Table 5-5: Arithmetic operators ...................................................................................................5-33Table 5-6: Truth tables for bitwise operations............................................................................5-34Table 5-7: Examples of bitwise operations.................................................................................5-34Table 5-8: Comparison operators ................................................................................................5-35Table 5-9: Wildcard characters used with like...........................................................................5-37Table 5-10: Truth tables for logical expressions...........................................................................5-38Table 5-11: Comparison operators ................................................................................................5-62Table 5-12: System procedures for login account management................................................5-67Table 5-13: Conversion of fixed-length to variable-length datatypes ......................................5-71Table 5-14: Column definition and null defaults ........................................................................5-75xiv List of Tables
  14. 14. Sybase SQL Server Release 11.0.xTable 5-15: Roles required for SQL commands ...........................................................................5-84Table 5-16: Roles required for system procedures ......................................................................5-85Table 5-17: Wildcard characters used in match strings ..............................................................5-88Table 5-18: Comparison operators ................................................................................................5-94Table 5-19: @@transtate values ....................................................................................................5-103Table 5-20: DDL commands allowed in transactions ...............................................................5-106Table 5-21: DDL commands not allowed in transactions ........................................................5-107Table 5-22: How rollbacks affect processing..............................................................................5-115Table 5-23: How rollbacks from errors affect processing.........................................................5-119Table 5-24: Rollbacks caused by duplicate key errors or rules violations .............................5-120Table 5-25: Global variables .........................................................................................................5-124Table 5-26: Using square brackets to search for wildcard characters.....................................5-133Table 5-27: Using the escape Clause ...........................................................................................5-134 SQL Server Reference Manual xv
  15. 15. Sybase SQL Server Release 11.0.xxvi List of Tables
  16. 16. Preface The SQL Server Reference Manual is a two-volume guide to Sybase SQL Server™ and the Transact-SQL® language. This volume, Volume 1, includes information about datatypes, Transact-SQL commands, built-in functions, and topics of general interest to Transact-SQL users. Volume 2 contains information about system procedures and catalog stored procedures.Audience This manual is intended as a reference tool for Transact-SQL users of all levels. It provides basic syntax and usage information for every command, function, system procedure, and catalog stored procedure.How to Use This Book This manual consists of the following chapters: • Chapter 1, “SQL Server Roadmap,” contains lists of tasks you can do with SQL Server and tells you which commands, system procedures, catalog stored procedures, built-in functions, and global variables you can use to accomplish them and which sections of this manual to read to get more information. • Chapter 2, “System and User-Defined Datatypes,” describes the system and user-defined datatypes that are supplied with SQL Server and indicates how to use them to create user-defined datatypes. • Chapter 3, “Transact-SQL Commands,” contains reference information for every Transact-SQL command. Particularly complex commands, such as select, are divided into subsections. For example, there are reference pages on the compute clause and on the group by and having clauses of the select command. • Chapter 4, “Transact-SQL Functions,” contains reference information for the SQL Server aggregate functions, datatype conversion functions, date functions, mathematical functions, row aggregate functions, string functions, system functions, and text and image functions. SQL Server Reference Manual xvii
  17. 17. Related Documents Sybase SQL Server Release 11.0.x • Chapter 5, “Transact-SQL Topics,” contains information about topics of general interest. Each topic describes the commands, system procedures, and functions that provide a particular type of functionality in Transact-SQL. • The Index contains entries for both volumes of the SQL Server Reference Manual.Related Documents Other manuals that you may find useful are: • SQL Server installation and configuration guide, which describes the installation procedures for SQL Server and documents operating system-specific system administration, security administration, and tuning tasks. • SQL Server Performance and Tuning Guide, which explains how to tune SQL Server for maximum performance. The book includes information about database design issues that affect performance, query optimization, how to tune SQL Server for very large databases, disk and cache issues, and the effects of locking and cursors on performance. • SQL Server Reference Supplement, which contains a list of Transact- SQL reserved words, definitions of system tables, a description of the pubs2 sample database, a list of SQL Server error messages, and other reference information that is common to all the SQL Server manuals. • SQL Server Security Administration Guide, which explains how to use the security features provided by SQL Server to control user access to data. The manual includes information about how to add users to the server, give them controlled access to database objects and procedures, and manage remote servers. • SQL Server Security Features User’s Guide, which explains how to use the security features of SQL Server. • SQL Server System Administration Guide, which provides in-depth information about administering servers and databases. The manual includes instructions and guidelines for managing physical resources and user and system databases, and specifying character conversion, international language, and sort order settings.xviii