Groups | Blog | Home
all groups > sql server programming > august 2004 >

sql server programming : Few queries


Amit
8/25/2004 11:49:02 PM
Hi,

A] Regarding Identity column values:
Create table A(id int identity(1,1) Primary key)
For above table,
1. What will happen to the insert statement when the
identity column value has reached the maximum value
defined for integer ?
My answer: Should generate an error message.

2. Will identity value ever be negative ?
My answer: NO

B] Can we execute join queries on tables in two different
databases ?

C] Can we have DML statements in the body of function ?
My answer: yes but only for table variables declared
inside the function / in the return type.

Thanks in advance.
Tamas Bojcan - bojci
8/26/2004 9:06:09 AM
Hi,

A.) The identity value is numeric(38,0) not integer. This value casted to
the type of identity column which can be tinyint, smallint, int, bigint,
decimal, numeric. You get error message if the identity value greater than
the max. value of the column's datatype. The identity can be negative just
set the increment value to less than zero.

B.) Use four part names => server.database.owner.object


[quoted text, click to view]

Uri Dimant
8/26/2004 10:47:24 AM
Amit
1) Correct
2) Incorrect
CREATE TABLE #Temp
(
col INT NOT NULL IDENTITY (-100,1)
)
INSERT #Temp DEFAULT VALUES
INSERT #Temp DEFAULT VALUES
SELECT * FROM #Temp

3)
You cannot create DRI between different databases
4)
Correct






[quoted text, click to view]

AddThis Social Bookmark Button