|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Inserting Multiple Records from One Database to Another
These are the following two tables I have:
UnitMaterial: UnitId MaterialId InUnit Training Approval PendingUnitMaterial UnitId MaterialId InUnit I have the following records in my PendingUnitMaterial Table: 1, 5, 0 2, 5, 1 3, 5, 1 I want to get these multiple records and insert them into my UnitMaterial Table but do not know how. I have looked at other places but the syntax is screwing me up. Any help would be greatly appreciated. Thanks |
|
#2
|
|||
|
|||
|
The easy way is to query pendingUnitMaterial, and then loop over than and insert each one into the unitMaterial table.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
I have tried doing that and I get this error:
Error Executing Database Query. [Macromedia][SQLServer JDBC Driver][SQLServer]Incorrect syntax near the keyword 'VALUES'. Here is my code: <cfoutput> <cfquery name="UnitMaterial" datasource="****"> SELECT * FROM pendingunitmaterialView </cfquery> <cfloop query="UnitMaterial"> <cfquery name="insertUnitMaterials" datasource="****"> INSERT INTO dbo.unitmaterialView ( UnitId, MaterialId, InUnit, FacilityApproval, RaApproval VALUES ( #UnitMaterial.UnitId#, #UnitMaterial.MaterialId#, #UnitMaterial.InUnit#, 1, 1 ) </cfquery> </cfloop> </cfoutput> |
|
#4
|
|||
|
|||
|
uh, you need a closing parenthesis after the last column name.
|
|
#5
|
|||
|
|||
|
Oh wow I cant believe I didnt catch that. Sorry for the carelessness and thank you so much!
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Inserting Multiple Records from One Database to Another |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|