HI Kay, It looks to me like the select should be

select scope_identity() as formatid from format

i.e. the 'as' refers to the column rather than the table which is how I read
your sql.


On Jan 20, 2008 10:01 PM, Kay Smoljak <[EMAIL PROTECTED]> wrote:

> I have a site that uses an SQL Server database. I'm pretty sure this
> was working before but now it's not (shared hosting database, so I
> have no control over that part).
>
> Usually to return the last inserted ID, I run a select after an insert
> like so:
>
> <cfquery datasource="#dsn#" name="qry">
> SET NOCOUNT ON
> INSERT INTO Format (name)
> VALUES (<cfqueryparam cfsqltype="cf_sql_varchar" value="#name#">)
> SELECT SCOPE_IDENTITY() FROM Format AS FormatID
> SET NOCOUNT OFF
> </cfquery>
>
> Then refer to the last ID as qry.FormatID.
>
> However, it's now telling me that FormatID is not defined in qry. If I
> dump out the contents of qry, I see there's a column called
> "COMPUTED_COMLUMN_1" which has the value I want. But I'm curious as to
> why this has changed (like I said, I am 90% sure it wasn't like this
> last week) - is it a setting on the db server itself? Is there any
> problem referring directly to COMPUTED_COLUMN_1?
>
> Thanks,
> K.
>
> --
> Kay Smoljak
> business: www.cleverstarfish.com
> standards: kay.zombiecoder.com
> coldfusion: kay.smoljak.com
> personal: goatlady.wordpress.com
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:296934
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to