CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 MS SQL Equivalent for MySQL_INSERT_ID()

Print topic Send  topic

Author Message
MichaelMcDonald

Posts: 640
Posted: 01/09/2015, 12:30 AM

Does anyone have a working solution which does not use @@identity ?
_________________
Central Coast, NSW, Australia.

View profile  Send private message
eratech


Posts: 513
Posted: 01/17/2015, 5:23 PM

Michael - sorry no. I've used the @@identity. Only change is if I need the ID back I will put it in a stored proc so I can handle new or updates in same code and just return the appropriate ID (new or existing)

But still boils down to @@identity.

Is there a problem that you are finding with @@identity?

Eric
_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia
View profile  Send private message
MichaelMcDonald

Posts: 640
Posted: 02/02/2015, 1:28 PM

I have read that if the table is linked to another and a stored procedure exists to insert a record into the other table that @@identity could return the foreign key.
_________________
Central Coast, NSW, Australia.

View profile  Send private message
eratech


Posts: 513
Posted: 02/02/2015, 5:01 PM

Hmmm - I haven't heard that one about the foreign keys. Do you have a reference as I have a large MSSQL DB with lots of stored procs and I'd like to check.

I know there was (might still be) some possible errors with web apps and sessions getting mixed up with multiple inserts but that was rare anyway.

I *have* seen a weirdness with the IDENTITY setting on a table jump 10,000-ish numbers after a server re-start. The answer from MS was that the IDENTITY would be unique and incremented, but not necessarily sequential. Wasn't a huge deal but we lost about 10k possible member numbers.

Eric
_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia
View profile  Send private message
MichaelMcDonald

Posts: 640
Posted: 02/02/2015, 6:20 PM

just found the answer ...

@@identity can be a problem ...

http://blog.sqlauthority.com/2007/03/25/sql-server-iden...tity-of-record/
_________________
Central Coast, NSW, Australia.

View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.