Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 123»»»

Check Your SQL Server Identity Expand / Collapse
Author
Message
Posted Monday, July 25, 2005 4:00 PM
SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: Moderators
Last Login: Yesterday @ 12:08 PM
Points: 6,790, Visits: 1,904
Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/awarren/checkyoursqlserveridentity.asp

Andy
SQLAndy - My Blog!
Connect with me on LinkedIn
Follow me on Twitter
Post #204236
Posted Monday, August 1, 2005 6:59 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Wednesday, October 15, 2014 5:53 AM
Points: 598, Visits: 239

There is a mistake in the article.

Where it says "Returns a value of 5.", the line above should be scope_identity() instead of @@identity

 

 

Jim.




Post #206040
Posted Monday, August 1, 2005 7:20 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Wednesday, October 22, 2014 2:34 AM
Points: 1,151, Visits: 1,104
I've just started coding my first asp.net app and I'm glad to see that the approach I've taken matches the 'right answer' from the article!
Post #206043
Posted Monday, August 1, 2005 7:49 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 12:59 PM
Points: 2,555, Visits: 605
huh - this is a "neither here nor there" comment - just yesterday when I was browing through the ssc articles I read one by Brian that addressed the same topic...except his was with reference to triggers....

Brian's article

Brian also addresses IDENT_CURRENT() which should've gotten a mention in Andy's as well!!! Otherwise, as usual - an informative article!








**ASCII stupid question, get a stupid ANSI !!!**
Post #206063
Posted Monday, August 1, 2005 7:57 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Tuesday, June 9, 2009 8:13 AM
Points: 75, Visits: 3
Using this as a way to educate and bring developers up to speed makes sense. Using this as a question for a prospective DBA or developer is hogwash. There are too many assumptions made by this scenario to expect any developer or DBA to get the right answer without alot of conversation first.


Cheers,

Alex


Rogue DBA
Post #206065
Posted Monday, August 1, 2005 8:38 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 10:01 AM
Points: 10,282, Visits: 13,266
I have to disagree with Alex.  This is something any SQL Server DBA or developer should know and be able to answer relatively quickly.  We were "caught" by @@identity in SQL Server 7 because we had triggers that created an identity column as well.  Another location inf our compnay would have been caught by it as well in SQL 2000 had I not found their use of @@Identity and informed them of Scope_Identity and Ident_Current. 



Jack Corbett

Applications Developer

Don't let the good be the enemy of the best. -- Paul Fleming

Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
Post #206110
Posted Monday, August 1, 2005 8:39 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, September 12, 2007 9:18 AM
Points: 8, Visits: 1

I think that the fact that there are assumptions makes it even better.  In a case like this, conversation is necessary.  It's developers or DBAs going off half-cocked that very often causes problems.  That there could be problems forces a person to evaluate the possible problems using a solution would cause.  Sure, it'll take possibly a full minute (with the discussion of the environment) instead of 5 seconds to give a solution, but it'll be a solution that will work with less chance of failure.

Post #206111
Posted Monday, August 1, 2005 10:13 AM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Friday, December 13, 2013 8:04 PM
Points: 545, Visits: 255

Excellent Article.This is the problem wih every dba /developer

if you are senior and started carrier from sql server 7.0.

Now again this is year their is need of lot of learning for Yukon.

which is complete rewrite, not patch work to sql2000  



Kindest Regards,

Sameer Raval [Sql Server DBA]
Geico Insurance
RavalSameer@hotmail.com

Post #206177
Posted Monday, August 1, 2005 10:28 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Wednesday, October 22, 2014 12:34 PM
Points: 31,181, Visits: 15,626
I think it's a great question. If you are presented with any question in an interview it won't be with a complete understanding of the situation. That's why you ask questions and look to answer the question. Your thought process and interaction when someone asks you something is critical to both sides learning how you will fit in.







Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #206186
Posted Monday, August 1, 2005 12:35 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Wednesday, September 24, 2014 1:20 PM
Points: 1,276, Visits: 1,135

I think it's a fair/decent question.  A good job candidate should be prepared to ask the only relevant question when presented with this question:  "What is the scope?"  That's the only piece of information you need in order to determine which method of returning the last inserted identity value is appropriate.

Another good interview question involves how to retrieve a GUID after an INSERT.

Post #206230
« Prev Topic | Next Topic »

Add to briefcase 123»»»

Permissions Expand / Collapse