Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
label
Posting Yak Master
197 Posts |
Posted - 2003-04-28 : 12:27:23
|
| What's the best way to get an Indentity/Unique ID from a record after adding it?For instance My stored proc is this: _____________________________________________CREATE PROCEDURE dbo.ap_add_download_page@username varchar(50), @page_name varchar(50), @page_desc varchar(200), @pageid int outputASbegin set nocount on insert into download_pages (page_name, page_description, created_by, created_on) select @page_name, @page_desc, (select userid from users where email=@username), getdate()EndGO____________________________________________So what's the line I need to add to populate the @Pageid output parameter?Thanks. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2003-04-28 : 12:30:30
|
| SELECT @pageid = @@IDENTITYAlso have a look at SCOPE_IDENTITY and IDENT_CURRENT.Tara |
 |
|
|
label
Posting Yak Master
197 Posts |
Posted - 2003-04-28 : 13:56:27
|
quote: SELECT @pageid = @@IDENTITYAlso have a look at SCOPE_IDENTITY and IDENT_CURRENT.Tara
Thanks. I'll do that. |
 |
|
|
|
|
|