Skip to content

Instantly share code, notes, and snippets.

@zarkosusnjar
Created August 26, 2010 08:06
Show Gist options
  • Save zarkosusnjar/551033 to your computer and use it in GitHub Desktop.
Save zarkosusnjar/551033 to your computer and use it in GitHub Desktop.
<cfquery name="test" datasource="#this.dsn#" result="testing">
<!--- DECLARE temp table --->
DECLARE @resultSet TABLE( no INT )
<!--- INSERT last current identity value into temp table --->
INSERT INTO @resultSet (no) VALUES (IDENT_CURRENT('contacts'));
INSERT INTO contacts (
firstname
,lastname
)
SELECT <cfqueryparam cfsqltype="cf_sql_varchar" value="Marko">
,<cfqueryparam cfsqltype="cf_sql_varchar" value="Simic">
UNION ALL
SELECT <cfqueryparam cfsqltype="cf_sql_varchar" value="Boris">
, <cfqueryparam cfsqltype="cf_sql_varchar" value="Huskic"> ;
<!--- INSERT last inserted identity value into temp table --->
INSERT INTO @resultSet (no) VALUES (scope_identity());
<!--- SELECT and return values from temp table --->
SELECT * from @resultSet;
</cfquery>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment