Re: _ID NUMBER
From: Aaron Bertrand - MVP (aaron_at_TRASHaspfaq.com)
Date: 05/21/04
- Next message: Tom Edelbrok: "Re: Can error messages in Query Analyzer be suppressed?"
- Previous message: Anith Sen: "Re: Probably a simple question"
- In reply to: David Portas: "Re: _ID NUMBER"
- Next in thread: Louis Davidson: "Re: _ID NUMBER"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 21 May 2004 11:27:44 -0400
Great, thanks for the explanation. I have an article that recommends
SCOPE_IDENTITY() and it's the first I've heard of that there were any
limitations...
-- Aaron Bertrand SQL Server MVP http://www.aspfaq.com/ "David Portas" <REMOVE_BEFORE_REPLYING_dportas@acm.org> wrote in message news:k7qdnSY9MZFugzPd4p2dnA@giganews.com... > With an INSTEAD OF INSERT trigger the INSERT happens out of scope so > SCOPE_IDENTITY is NULL > > CREATE TABLE Table1 (i INTEGER IDENTITY PRIMARY KEY, x INTEGER NOT NULL > UNIQUE) > > GO > CREATE TRIGGER trg_Table1 ON Table1 INSTEAD OF INSERT > AS > INSERT INTO Table1 (x) > SELECT x FROM Inserted > GO > > INSERT INTO Table1 (x) VALUES (1) > SELECT SCOPE_IDENTITY(), IDENT_CURRENT('Table1') > > Result: > > ---------------------------------------- --------------------------------- -- > ----- > NULL 1 > > > (Tested on Enterprise, SP3) > > As Louis says, you can use the natural key to retrieve the value. > > -- > David Portas > SQL Server MVP > -- > >
- Next message: Tom Edelbrok: "Re: Can error messages in Query Analyzer be suppressed?"
- Previous message: Anith Sen: "Re: Probably a simple question"
- In reply to: David Portas: "Re: _ID NUMBER"
- Next in thread: Louis Davidson: "Re: _ID NUMBER"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|