Transact-SQL Reference Errata

The following changes should be made to the Microsoft SQL Server Transact-SQL Reference for Microsoft SQL Server 6.0.

A.    Show Generic Syntax

This example shows the generic syntax for using the IDENTITY property.

SET IDENTITY_INSERT tablename ON
go
DECLARE @minidentval column_type
DECLARE @nextidentval column_type
SELECT @minidentval = MIN(IDENTITYCOL) FROM tablename
IF @minidentval = IDENT_SEED('tablename')
    SELECT @nextidentval = MIN(IDENTITYCOL) + IDENT_INCR('tablename')
    FROM tablename t1
    WHERE IDENTITYCOL BETWEEN IDENT_SEED('tablename') AND 
        MAX(column_type) AND
        NOT EXISTS (SELECT * FROM tablename t2
            WHERE t2.IDENTITYCOL = t1.IDENTITYCOL + 
                IDENT_INCR('tablename'))
ELSE
    SELECT @nextidentval = IDENT_SEED('tablename')
SET IDENTITY_INSERT tablename OFF
  
B.    Check image Table for Gaps

This example shows how to use the IDENTITY property on a table called image that has two columns: the first column called id_num, which is an increasing identification number, and the second column called company_name.

-- Create the image table
CREATE TABLE image (id_num int IDENTITY(1,1), company_name varchar)
INSERT image(company_name) VALUES ('A Company Name')
INSERT image(company_name) VALUES ('Another Company Name')
-- Set IDENTITY_INSERT on and utilize in image table
SET IDENTITY_INSERT image ON
go
DECLARE @minidentval smallint
DECLARE @nextidentval smallint
SELECT @minidentval = MIN(IDENTITYCOL) FROM image
 IF @minidentval = IDENT_SEED('image')
     SELECT @nextidentval = MIN(IDENTITYCOL) + IDENT_INCR('image')
     FROM image t1
     WHERE IDENTITYCOL BETWEEN IDENT_SEED('image') AND 32766 and NOT EXISTS (SELECT * FROM image t2
         WHERE t2.IDENTITYCOL = t1.IDENTITYCOL + IDENT_INCR('image'))
 ELSE
     SELECT @nextidentval=IDENT_SEED('image')
SET IDENTITY_INSERT image OFF
  
EXEC sp_addumpdevice 'disk', 'disk_dev1', 'c:\\dumps\diskdev1.dmp'
  
Datatype SUM or AVG is of datatype
tinyint int
smallint int
int int
smallmoney money
money money
real float
float float
decimal more precise decimal, if necessary
numeric more precise numeric, if necessary


ATTRIBUTE_ID
ATTRIBUTE_NAME
description

ATTRIBUTE_VALUE
13 TABLE_LENGTH

Specifies the maximum number of characters for a table name.

30
14 MAX_QUAL_LENGTH

Specifies the maximum length of the name for a table qualifier (the first part of a three-part table name).

30
15 COLUMN_LENGTH

Specifies the maximum number of characters for a column name.

30
16 IDENTIFIER_CASE

Specifies the user-defined names (table names, column names, stored procedure names) in the database (the case of the objects in the system catalogs).

MIXED or SENSITIVE, depending upon whether SQL Server is set to case-sensitive or case-insensitive.
17 TX_ISOLATION

Specifies the initial transaction isolation level the server assumes, which corresponds to an isolation level defined in ANSI SQL-92.

2
18 COLLATION_SEQ

Specifies the ordering of the character set for this server.

charset ID
19 SAVEPOINT_SUPPORT

Specifies whether the underlying DBMS supports named savepoints.

Y
20 MULTI_RESULT_SETS

Specifies whether the underlying database or the gateway itself supports multiple results sets (multiple statements can be sent through the gateway with multiple results sets returned to the client).

Y
22 ACCESSIBLE_TABLES

Specifies whether in the sp_tables stored procedure, the gateway returns only tables, views, and so on that are accessible by the current user (that is, the user who has at least SELECT privileges for the table).

Y
100 USERID_LENGTH

Specifies the maximum number of characters for a username.

30
101 QUALIFIER_TERM

Specifies the DBMS vendor term for a table qualifier (the first part of a three-part name).

Database
102 NAMED_TRANSACTIONS

Specifies whether the underlying DBMS supports named transactions.

Y
103 SPROC_AS_LANGUAGE

Specifies whether stored procedures can be executed as language events.

Y
104 ACCESSIBLE_SPROC

Specifies whether in the sp_stored_procedures stored procedure, the gateway returns only stored procedures that are executable by the current user.

Y
105 MAX_INDEX_COLS

Specifies the maximum number of columns in an index for the DBMS.

16
106 RENAME_TABLE

Specifies whether tables can be renamed.

Y
107 RENAME_COLUMN

Specifies whether columns can be renamed.

Y
108 DROP_COLUMN

Specifies whether columns can be dropped.

N
109 INCREASE_COLUMN_LENGTH

Specifies whether column size can be increased.

N
110 DDL_IN_TRANSACTION

Specifies whether DDL statements can appear in transactions.

Returns Y if SQL Server version 6.5 or later is running and N for earlier releases.
111 DESCENDING_INDEXES

Specifies whether descending indexes are supported.

N
112 SP_RENAME

Specifies whether a stored procedure can be renamed.

Y
113 REMOTE_SPROC

Specifies whether stored procedures can be executed through the remote stored procedure functions in DB-Library.

Y
500 SYS_SPROC_VERSION

Specifies the version of the catalog stored procedures currently implemented.

Current version number