So there's no way to get it to return the id from inside that statement? Maybe assign it to a variable in there?
> -----Original Message----- > From: Adrian Lynch [mailto:[EMAIL PROTECTED] > Sent: Thursday, February 16, 2006 7:46 PM > To: CF-Talk > Subject: RE: if not exists (SQL) question > > My guess would be that because the first SELECT is part on the condition, > IF > NOT EXISTS(SELECT...), it doesn't return a result set. Move the SELECT out > of the condition and do some different logic. > > Adrian > > -----Original Message----- > From: Russ [mailto:[EMAIL PROTECTED] > Sent: 17 February 2006 00:37 > To: CF-Talk > Subject: if not exists (SQL) question > > > I have a query similar to the following: > > > > declare @emailLinkID int > > if not exists ( > > select emailLinkID from emailLinks > > where linkURL='https://www.someurl.com' > > > ) > > begin > > insert into emailLinks ( > > linkURL > > ) values ( > > 'https://www.someurl.com, > > ) > > set @emailLinkID = @@IDENTITY > > select @emailLinkID as emailLinkID > > end > > > > > > This works fine when the record doesn't exist. But it doesn't return the > id > if the record does exist. What am I doing wrong? > > > > Russ > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:232696 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

