Ask a Question related to Microsoft SQL / MS SQL Server, Design and Development.
-
Narayana Vyas Kondreddi #1
Re: accessing current written record
See @@IDENTITY and SCOPE_IDENTITY( ) in SQL Server Books Online.
--
HTH,
Vyas, MVP (SQL Server)
[url]http://vyaskn.tripod.com/[/url]
What hardware is your SQL Server running on?
[url]http://vyaskn.tripod.com/poll.htm[/url]
"James Hall" <halljh@dshs.wa.gov> wrote in message
news:014301c33f3a$5cee73d0$a501280a@phx.gbl...
I am working on a multiple table insert. My master table
has an id field that is an identity field. Before writing
records to the related tables, I need to find out what the
id is that was just created. I seem to remember being able
to get to it by accessing a system cache - probably
tempdb. I can't find my example - anybody know how to do
this?
Thank you,
Jim.
Narayana Vyas Kondreddi Guest
-
Either BOF or EOF is True, or the current record hasbeen deleted. Requested operation requires a current record
Can anyone pls help? I am getting the following error when search my database. "ADODB.Field (0x800A0BCD Either BOF or EOF is True, or the... -
Accessing current user in Managed C++ Web Service?
Hi Everyone, I created a managed c++ web service and I would like to access the current user. For instance, in a C# web service, you would... -
Accessing the current datasource row and column?
How would i go about accessing a column in the currently binding row in a datagrids datasource the following code does not give me access to the... -
Query to insert into current record
It sounds as though you are using one file (table), and you want all this activity to take place within the one file. You don't say where (what... -
Drew Seale #2
Re: accessing current written record
If you are performing a single insert you can use the SCOPE_IDENTITY()
function to retrun the last identity value inserted within the same scope
(proc, etc.)
Ex:
declare @ident int
INSERT ...
set @ident = SCOPE_IDENTITY()
--Drew
"James Hall" <halljh@dshs.wa.gov> wrote in message
news:014301c33f3a$5cee73d0$a501280a@phx.gbl...> I am working on a multiple table insert. My master table
> has an id field that is an identity field. Before writing
> records to the related tables, I need to find out what the
> id is that was just created. I seem to remember being able
> to get to it by accessing a system cache - probably
> tempdb. I can't find my example - anybody know how to do
> this?
>
> Thank you,
> Jim.
Drew Seale Guest
-
Aaron Bertrand - MVP #3
Re: accessing current written record
DECLARE @id INT
INSERT tbl(col_list) VALUES(val_list)
SELECT @id = @@IDENTITY
PRINT @id
If using SQL Server 2000, replace @@IDENTITY with SCOPE_IDENTITY()
(It's always helpful to post the version of SQL Server you're using; the
solution can be different.)
"James Hall" <halljh@dshs.wa.gov> wrote in message
news:014301c33f3a$5cee73d0$a501280a@phx.gbl...> I am working on a multiple table insert. My master table
> has an id field that is an identity field. Before writing
> records to the related tables, I need to find out what the
> id is that was just created. I seem to remember being able
> to get to it by accessing a system cache - probably
> tempdb. I can't find my example - anybody know how to do
> this?
>
> Thank you,
> Jim.
Aaron Bertrand - MVP Guest



Reply With Quote

