ExamNotes.net  -  IT certification portal

ForumsCertResearchTop sitesNewslettersFree email
HomeRegister


Exams Notes
Practice exams
Exam games
Questions by email
Online training
Training videos
College degrees
Boot camps
Book store
Links directory
Tell a friend
For webmasters




General discussions > Public newsgroups > microsoft.public.sqlserver.server > How to get autonumber assigned to the insert ?

Show a Printable Version
Email This Page to Someone!
Receive updates to this thread



Author How to get autonumber assigned to the insert ?
C.Sivakumar
Guest




Registered: Not Yet
Location:
Country:
State:
Certifications:
Working on:

Total Posts: N/A
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

Old Post 10-06-02 03:07 AM
Reply w/Quote Edit/Delete Message IP: Logged
All times are GMT.
Post new thread   Post reply


Forum Jump:
Rate This Thread:
Forum Rules:
Who Can Read The Forum? Any registered user or guest.
Who Can Post New Topics? Any registered user.
Who Can Post Replies? Any registered user.
Changes: Messages can be edited by their author.
Posts: HTML code is OFF. Smilies are ON. vB code is ON. [IMG] code is OFF.
 

ExamNotes forum archive


Powered by: vBulletin 2.2.8
Copyright ©2000, Jelsoft Enterprises Limited.

  Free Braindumps | mcse braindumps