Retrieving Identity value after inserting a record

Retrieving Identity value after inserting a record

Post by Doug Shoke » Sat, 07 Oct 2000 04:00:00



I wish to call on a stored procedure to insert a row and then return the
value of the identity field for that new record.

How can the sp get that value after it inserts the record?

Thanks in advance,

Doug Shokes

 
 
 

Retrieving Identity value after inserting a record

Post by BP Margoli » Sat, 07 Oct 2000 04:00:00


Doug,




It is not influenced by any other activity happening on other connections.

----------------------------------------------------------------
BP Margolin
Please reply only to the newsgroups.
When posting, inclusion of SQL (CREATE TABLE ..., INSERT ..., etc.) which
can be cut and pasted into Query Analyzer is appreciated.


Quote:> I wish to call on a stored procedure to insert a row and then return the
> value of the identity field for that new record.

> How can the sp get that value after it inserts the record?

> Thanks in advance,

> Doug Shokes


 
 
 

Retrieving Identity value after inserting a record

Post by Doug Shoke » Sun, 08 Oct 2000 09:38:31


Thank you.

Personal note: I am enjoying the heck out of learning about the SQL Server.
It's a learning curve I knew I'd have to climb some day.  But the results
have been spectacular!!  Access summary reports that pulled 20-30 MB of data
over the wire are now being processed on the server and only the final
summary info retrieved.  One-fifth the time and about one ten-thousandth the
traffic.  But it's such a different programming paradigm from the purely Jet
world I come from.

Do you use a TSQL de*?  I have tried the Sylvain Faust de* demo
( a year ago) and I know there is one in VS 6 Enterprise but have not used
it.

Once again, your expertise and, even more importantly, your willingness to
disseminate it freely are greatly appreciated. There always seem to be a few
extraordinary folks on each newsgroup who give far more than they receive.


> Doug,




connection.
> It is not influenced by any other activity happening on other connections.

> ----------------------------------------------------------------
> BP Margolin
> Please reply only to the newsgroups.
> When posting, inclusion of SQL (CREATE TABLE ..., INSERT ..., etc.) which
> can be cut and pasted into Query Analyzer is appreciated.



> > I wish to call on a stored procedure to insert a row and then return the
> > value of the identity field for that new record.

> > How can the sp get that value after it inserts the record?

> > Thanks in advance,

> > Doug Shokes

 
 
 

Retrieving Identity value after inserting a record

Post by BP Margoli » Sun, 08 Oct 2000 04:00:00


Doug,

First, thanks for the recognition that SQL Server and MS Access are very
different animals. One of the more frustrating types of posts that pop up
here frequently are: "I've upsized Access to SQL Server and it's slower ...
I thought it was going to be faster without any effort on my part." It is a
pleasure to deal with someone who understands the difference between a
client/server and a file/server database.

SQL Server 2000 has a built-in stored procedure de*.

I occasionally post "No one is born with this knowledge", and that goes for
me too. There are numerous individuals, many from these newsgroups, to whom
I owe an enormous debt of gratitude for whatever SQL Server knowledge I
have. The one thing that I never expected when I started on these newsgroups
has turned out to be in fact the single most important thing ... I have
learned very more from these newsgroups than I can ever hope to give back.

Hang around, continue to ask questions, volunteer answers, don't get **too
upset** when you post something that is wrong ... after a while, you
actually almost begin to be grateful, because someone is adding to your
knowledge ... and welcome to the newsgroup!

----------------------------------------------------------------
BP Margolin
Please reply only to the newsgroups.
When posting, inclusion of SQL (CREATE TABLE ..., INSERT ..., etc.) which
can be cut and pasted into Query Analyzer is appreciated.


> Thank you.

> Personal note: I am enjoying the heck out of learning about the SQL
Server.
> It's a learning curve I knew I'd have to climb some day.  But the results
> have been spectacular!!  Access summary reports that pulled 20-30 MB of
data
> over the wire are now being processed on the server and only the final
> summary info retrieved.  One-fifth the time and about one ten-thousandth
the
> traffic.  But it's such a different programming paradigm from the purely J
et
> world I come from.

> Do you use a TSQL de*?  I have tried the Sylvain Faust de* demo
> ( a year ago) and I know there is one in VS 6 Enterprise but have not used
> it.

> Once again, your expertise and, even more importantly, your willingness to
> disseminate it freely are greatly appreciated. There always seem to be a
few
> extraordinary folks on each newsgroup who give far more than they receive.



> > Doug,




> connection.
> > It is not influenced by any other activity happening on other
connections.

> > ----------------------------------------------------------------
> > BP Margolin
> > Please reply only to the newsgroups.
> > When posting, inclusion of SQL (CREATE TABLE ..., INSERT ..., etc.)
which
> > can be cut and pasted into Query Analyzer is appreciated.



> > > I wish to call on a stored procedure to insert a row and then return
the
> > > value of the identity field for that new record.

> > > How can the sp get that value after it inserts the record?

> > > Thanks in advance,

> > > Doug Shokes