Groups | Blog | Home
all groups > sql server (alternate) > january 2004 >

sql server (alternate) : Adding entry to DB and getting unique ID at the same time


alex NO[at]SPAM totallynerd.com
1/29/2004 11:36:34 AM
Hi all,

I'm writing a website with Cold Fusion and when a user submits a
request and it's stored in the MS SQL database, I want the unique ID
(Identity field in table) to be given to the user on screen plus
emailed to user.

Now can I store data to the database (where the ID is created) and
return this as a variable in the same statement? I've seen this done
on many websites, but I have no idea how to do it in one step.

Thanks,

Eric Sabine
1/29/2004 2:42:41 PM
Return to the user the value from @@identity (check this out in the BOL).
You can also have SQL trigger off the email if this fits within your
project's stated performance requirements. Send the email via
xp_smtp_sendmail(http://sqldev.net/xp/xpsmtp.htm) But basically your
requirement to do it in 1 step could all be handled with a stored procedure.

hth
Eric


[quoted text, click to view]

AddThis Social Bookmark Button