You could do it like this...
CFTRANSACTION
CFTRY
CFQUERY NAME=qryID DATASOURCE=#Application.DSN#
SET NOCOUNT ON
INSERT INTO foo (name)
VALUES ('Homer Simpson')
Scott - do you mean the identity value of a newly inserted record, or to
select the ID value when you don't know the name of the identity column?
-Original Message-
From: Scott Van Vliet [mailto:[EMAIL PROTECTED]]
Sent: Sunday, February 17, 2002 2:22 PM
To: CF-Talk
Subject: Dynamically
Does anyone out there know of a way to dynamically grab the identity
column from a table in a select statement?
if you mean the metadata for which column has an IDENTITY property, no.
but i suppose you could query the syscolumns' status column for IDENTITY
(0x80).
---
Outgoing mail is
CFTRANSACTION
CFTRY
since you have only one cfquery cftransaction's not going to be doing much
in this example.
CFQUERY NAME=qryID DATASOURCE=#Application.DSN#
SET NOCOUNT ON
INSERT INTO foo (name)
VALUES ('Homer Simpson')
SELECT PrimaryKey = @@IDENTITY
SET NOCOUNT OFF
/CFQUERY
Jeff - The second: select the ID value when you don't know the name of
the identity column...
Is this even possible?
Thanks!
-Original Message-
From: Jeff Beer [mailto:[EMAIL PROTECTED]]
Sent: Sunday, February 17, 2002 11:42 AM
To: CF-Talk
Subject: RE: Dynamically Obtaining IDENTITY
Scott - do you mean the identity value of a newly inserted record, or to
select the ID value when you don't know the name of the identity column?
you don't need to know the IDENTITY column to get @@IDENTITY.
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system
11:42 AM
To: CF-Talk
Subject: RE: Dynamically Obtaining IDENTITY Column
Scott - do you mean the identity value of a newly inserted record, or to
select the ID value when you don't know the name of the identity column?
-Original Message-
From: Scott Van Vliet [mailto:[EMAIL PROTECTED]]
Sent
, please let me
know!
-Original Message-
From: Jeff Beer [mailto:[EMAIL PROTECTED]]
Sent: Sunday, February 17, 2002 11:42 AM
To: CF-Talk
Subject: RE: Dynamically Obtaining IDENTITY Column
Scott - do you mean the identity value of a newly inserted record, or to
select the ID value when you
Subject: RE: Dynamically Obtaining IDENTITY Column
Scott - do you mean the identity value of a newly inserted record, or to
select the ID value when you don't know the name of the identity column?
-Original Message-
From: Scott Van Vliet [mailto:[EMAIL PROTECTED]]
Sent: Sunday, February
: Sunday, February 17, 2002 7:21 PM
To: CF-Talk
Subject: RE: Dynamically Obtaining IDENTITY Column
Ooops
I meant
cfset yourcolumn = listfirst(firstquery.columnlist)
At 10:18 PM 2/17/2002 -0500, you wrote:
Well, if you just want to know the name of the first column in your
table,
why don't you do
Message-
From: Scott Van Vliet [mailto:[EMAIL PROTECTED]]
Sent: Sunday, February 17, 2002 11:26 PM
To: CF-Talk
Subject: RE: Dynamically Obtaining IDENTITY Column
This works as well, however, using SQL functions can be faster.
SELECT COL_NAME(OBJECT_ID('#tablename#'),1) As IDColumn
This does
11 matches
Mail list logo