How to get autonumber assigned to the insert ?
Hi,
-- First create a SP like this:-
-- ***********
CREATE PROCEDURE [dbo].[SP_TestSiva]
AS
begin
DECLARE @mem_ID uniqueidentifier
insert into tstSiva(fld1) values ('row1test')
select @mem_ID = (select ID from tstSiva)
select @mem_ID as retval
end
GO
-- ***********
-- then run it like
exec sp_testSiva
-- you will see something like this:-
FD2A5788-D7D6-45CC-9BC1-26E49FC8C420
select * from tstSiva
FD2A5788-D7D6-45CC-9BC1-26E49FC8C420 row1test
hope that helps!!
Also do you know
Is there any date or AddMonth functions in SQL Server 2000
at all?
Basically I am trying to add a month to a given date
inside a Stored Procedure
For example like :
DECLARE @Next_Month datetime, @Second_Month datetime
-- trying to add one month from today's date
select @Next_Month = Add_Month(GETDATE(), 1)
-- trying to add two months from todays date
select @Second_Month = Add_Month(GETDATE(), 2)
thanks a lot
siva
>-----Original Message-----
>Hi,
>
>I have a user table that contain a autonumber ID as
primary key. I would to
>write a stored procedure to insert record into this table
and also returns
>the autonumber ID as the return value of the stored
procedure. But, how do
>I capture the autonumber generated by each insert
transaction since Insert
>don't return any value.
>
>Thanks
>
>Jean
>
>
>
>
>.
>
Report this post to a moderator
|