Thank you, that worked perfectly. Don't know why it wasn't letting me do the same select statement inside the if...
> -----Original Message----- > From: Sixten Otto [mailto:[EMAIL PROTECTED] > Sent: Wednesday, August 16, 2006 8:05 PM > To: CF-Talk > Subject: Re: ColdFusion var bug? > > >Is there a way to make it return a value if the id is already in the > >database? > > How about: > > declare @tableId int > select @tableId = tableid from table > where someotherID=#arguments.someotherID# > > if @tableId is null > begin > insert into table ( > someotherId > ) values ( > #arguments.someotherID# > ) > set @tableId = @@IDENTITY > end > select @tableId as tableId > > Sixten > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:250167 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4