You probably can with a stored procedure depending on the DB that you are
using.

You can also do this by querying the DB before doing the insert then using
CFIF logic within the query statements to define the database. Or leave the
logic outside of the query and use a variable to store the DB name and use
the variable within the query. This works regardless of the DB.

Ray Thompson
Tau Beta Pi (www.tbp.org)
The Engineering Honor Society
865-546-4578 
-----Original Message-----
From: Duane Boudreau [mailto:[EMAIL PROTECTED] 
Sent: Friday, February 17, 2006 12:42 PM
To: SQL
Subject: SQL Question

Is there anyway of doing an if/else statement inside an insert clause,
something like?

 

 

Insert    dbo.myTable (x,y,z)

 

Select   dbo.myOtherTable.fieldA, dbo.myOtherTable.fieldB,

if (dbo.myOtherTable.fieldC != 0) dbo.myOtherTable.fieldC else
dbo.myOtherTable.fieldD

 

>From    dbo.myOtherTable

 

Where   dbo.myOtherTable.fieldN = 1

 

 

 






~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:6:2430
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/6
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:6
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.6
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to