You can write a stored procedure for sql server 7.0 like this:

create procedure insertstuff

@inputvariable1 int,
@inputvariable2 varchar(20),
@inputvariable3 int

AS

Declare @primarykey int

insert into table(field1,field2,field3) values
(@inputvariable1,@inputvariable2,@inputvariable3)

Select @primarykey = @@identity


the cfquery would look like this:

<cfquery name="blah" datasource="whatever">
        {call insertstuff(#variable1#,'#variable2#',#variable3#)
</cfquery>

<cfoutput>
        My primary key is #blah.primarykey#
</cfoutput>

-----Original Message-----
From: Jeff Green [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 27, 2001 2:51 PM
To: CF-Talk
Subject: Passing back the ID field from an Insert


Hey all this my be a bit OT,

I want to get the primary key / ID field passed back to CF when I make an
INSERT into SQL server 7.0.  Im aware that this can be done with triggers.
I was hoping some one could copy and paste some example code for me.

TIA,
Jeff
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to