?
Solved

Append query with some field values constant

Posted on 2010-01-07
2
Medium Priority
?
367 Views
Last Modified: 2012-05-08
What is the syntax to append a constant value to a table?

Something like...

INSERT INTO tblResults(ProgramGroupIndex, ProgramIndex, Rank, Item)
SELECT "1", "1", tblIntermed.Rank, tblIntermed.Item
FROM tblIntermed


strSQL = _
    "INSERT INTO tblFinalOutput (ProgramGroupIndex, ProgramIndex, Rank, Item, RDCNumber, Alignment, ChannelType, FreightPayment, Sourcing, Flow, ChannelNumber, ContainerSize, LandingCoast, Consolidation, FreightType, GOSTRAT, MiscAddOn1, FacilityOHCost, StoreOHCost, TransitCost, TotInvCost, Inbd, Obd, TotFrt, FacilityRDC, Store, TotHand, FacilityOHDol, StoreOHDol, TransitDol, TotInvDol, DOS_F_Inter, DOS_S_Inter, DollarVolume, CubeVolume, WtVolume, TotSales, TotalPallets, COGS, COGSAfterRebate, COGSAfterRebateShrink, ConsolidationCost, ConCOGSAddon, LGSFee, Duties, BALCFee, OtherImpFee, Inv_SSFacilityUnit, Inv_SSStoreUnit, Inv_CycleFacilityUnit, Inv_CycleStoreUnit, Inv_PMinStoreUnit, Inv_SSFacilityCost, Inv_SSStoreCost, Inv_CycleFacilityCost, Inv_CycleStoreCost, Inv_TIVendor2FacilityCost, Inv_TIFacility2RDCCost, Inv_TIRDC2StoreCost, Inv_PMinStoreCost, Inv_VendorTermsCost, Inv_SSFacilityDol, Inv_SSStoreDol, Inv_CycleFacilityDol, Inv_CycleStoreDol, " + _
    " Inv_TIVendor2FacilityDol, Inv_TIFacility2RDCDol, Inv_TIRDC2StoreDol, Inv_PMinStoreDol, Inv_VendorTermsDol, TSLFac, TSLStore, RevByItem, ProfitByItem, OHSSCubeFac, OHSSCubeStore, OHCICubeFac, OHCICubeStore, SPMCube, OccupancyCost, CurrentFacTSL, CurrentStoreTSL, SellingWeeks, DemandPerYr, StockedStores, OutboundSU, OutboundSUClass, StockOutDaysFac, LSM, CurrentJobLot, ProposedJobLot, JobLotIncrease, OBTransCostForItemELC, HandCostForItemELC)" + _
    " SELECT [qry-TopSolItemLevel_Final].Rank, [qry-TopSolItemLevel_Final].Item, [qry-TopSolItemLevel_Final].RDCNumber, [qry-TopSolItemLevel_Final].Alignment, [qry-TopSolItemLevel_Final].ChannelType, [qry-TopSolItemLevel_Final].FreightPayment, [qry-TopSolItemLevel_Final].Sourcing, [qry-TopSolItemLevel_Final].Flow, [qry-TopSolItemLevel_Final].ChannelNumber, [qry-TopSolItemLevel_Final].ContainerSize, [qry-TopSolItemLevel_Final].LandingCoast, [qry-TopSolItemLevel_Final].Consolidation, [qry-TopSolItemLevel_Final].FreightType, [qry-TopSolItemLevel_Final].GOSTRAT, [qry-TopSolItemLevel_Final].MiscAddOn1, [qry-TopSolItemLevel_Final].FacilityOHCost, [qry-TopSolItemLevel_Final].StoreOHCost, [qry-TopSolItemLevel_Final].TransitCost, [qry-TopSolItemLevel_Final].TotInvCost, [qry-TopSolItemLevel_Final].Inbd, [qry-TopSolItemLevel_Final].Obd, [qry-TopSolItemLevel_Final].TotFrt, [qry-TopSolItemLevel_Final].FacilityRDC, [qry-TopSolItemLevel_Final].Store, [qry-TopSolItemLevel_Final].TotHand," + _
    " [qry-TopSolItemLevel_Final].FacilityOHDol , [qry-TopSolItemLevel_Final].StoreOHDol, [qry-TopSolItemLevel_Final].TransitDol, [qry-TopSolItemLevel_Final].TotInvDol, [qry-TopSolItemLevel_Final].DOS_F_Inter, [qry-TopSolItemLevel_Final].DOS_S_Inter, [qry-TopSolItemLevel_Final].DollarVolume, [qry-TopSolItemLevel_Final].CubeVolume, [qry-TopSolItemLevel_Final].WtVolume, [qry-TopSolItemLevel_Final].TotSales, [qry-TopSolItemLevel_Final].TotalPallets, [qry-TopSolItemLevel_FinalDetail].COGS, [qry-TopSolItemLevel_FinalDetail].COGSAfterRebate, [qry-TopSolItemLevel_Final].COGSAfterRebateShrink, [qry-TopSolItemLevel_FinalDetail].ConsolidationCost, [qry-TopSolItemLevel_FinalDetail].ConCOGSAddon, [qry-TopSolItemLevel_FinalDetail].LGSFee, [qry-TopSolItemLevel_FinalDetail].Duties, [qry-TopSolItemLevel_FinalDetail].BALCFee1, [qry-TopSolItemLevel_FinalDetail].OtherImpFee, [qry-TopSolItemLevel_FinalDetail].Inv_SSFacilityUnit," + _
    " [qry-TopSolItemLevel_FinalDetail].Inv_SSStoreUnit, [qry-TopSolItemLevel_FinalDetail].Inv_CycleFacilityUnit, [qry-TopSolItemLevel_FinalDetail].Inv_CycleStoreUnit, [qry-TopSolItemLevel_FinalDetail].Inv_PMinStoreUnit, [qry-TopSolItemLevel_FinalDetail].Inv_SSFacilityCost, [qry-TopSolItemLevel_FinalDetail].Inv_SSStoreCost, [qry-TopSolItemLevel_FinalDetail].Inv_CycleFacilityCost, [qry-TopSolItemLevel_FinalDetail].Inv_CycleStoreCost, [qry-TopSolItemLevel_FinalDetail].Inv_TIVendor2FacilityCost," + _
    " [qry-TopSolItemLevel_FinalDetail].Inv_TIFacility2RDCCost, [qry-TopSolItemLevel_FinalDetail].Inv_TIRDC2StoreCost, [qry-TopSolItemLevel_FinalDetail].Inv_PMinStoreCost, [qry-TopSolItemLevel_FinalDetail].Inv_VendorTermsCost, [qry-TopSolItemLevel_FinalDetail].Inv_SSFacilityDol, [qry-TopSolItemLevel_FinalDetail].Inv_SSStoreDol, [qry-TopSolItemLevel_FinalDetail].Inv_CycleFacilityDol, [qry-TopSolItemLevel_FinalDetail].Inv_CycleStoreDol, [qry-TopSolItemLevel_FinalDetail].Inv_TIVendor2FacilityDol, [qry-TopSolItemLevel_FinalDetail].Inv_TIFacility2RDCDol, [qry-TopSolItemLevel_FinalDetail].Inv_TIRDC2StoreDol, [qry-TopSolItemLevel_FinalDetail].Inv_PMinStoreDol, [qry-TopSolItemLevel_FinalDetail].Inv_VendorTermsDol," + _
    " [qry-TopSolItemLevel_FinalDetail].TSLFac, [qry-TopSolItemLevel_FinalDetail].TSLStore, [qry-TopSolItemLevel_FinalDetail].RevByItem, [qry-TopSolItemLevel_FinalDetail].ProfitByItem, [qry-TopSolItemLevel_FinalDetail].OHSSCubeFac, [qry-TopSolItemLevel_FinalDetail].OHSSCubeStore, [qry-TopSolItemLevel_FinalDetail].OHCICubeFac, [qry-TopSolItemLevel_FinalDetail].OHCICubeStore, [qry-TopSolItemLevel_FinalDetail].SPMCube, [qry-TopSolItemLevel_FinalDetail].OccupancyCost, [qry-TopSolItemLevel_FinalDetail].CurrentFacTSL, [qry-TopSolItemLevel_FinalDetail].CurrentStoreTSL, [qry-TopSolItemLevel_FinalDetail].SellingWeeks, [qry-TopSolItemLevel_FinalDetail].DemandPerYr, [qry-TopSolItemLevel_FinalDetail].StockedStores, [qry-TopSolItemLevel_FinalDetail].OutboundSU, [qry-TopSolItemLevel_FinalDetail].OutboundSUClass, [qry-TopSolItemLevel_FinalDetail].StockOutDaysFac, [qry-TopSolItemLevel_FinalDetail].LSM, [qry-TopSolItemLevel_FinalDetail].CurrentJobLot, " + _
    " [qry-TopSolItemLevel_FinalDetail].ProposedJobLot, [qry-TopSolItemLevel_FinalDetail].JobLotIncrease, [qry-TopSolItemLevel_FinalDetail].OBTransCostForItemELC, [qry-TopSolItemLevel_FinalDetail].HandCostForItemELC" + _
    " FROM [qry-TopSolItemLevel_Final] INNER JOIN [qry-TopSolItemLevel_FinalDetail] ON ([qry-TopSolItemLevel_Final].Item = [qry-TopSolItemLevel_FinalDetail].Item) AND ([qry-TopSolItemLevel_Final].RDCNumber = [qry-TopSolItemLevel_FinalDetail].RDCNumber);"
    Call subCreateGenericQuery("qryFinalOutput", strSQL)

Open in new window

0
Comment
Question by:ltdanp22
2 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 2000 total points
ID: 26203594
>Something like...

>INSERT INTO tblResults(ProgramGroupIndex, ProgramIndex, Rank, Item)
?SELECT "1", "1", tblIntermed.Rank, tblIntermed.Item
> FROM tblIntermed


seems fine, which databse
0
 

Author Closing Comment

by:ltdanp22
ID: 31674206
just wanted to make sure.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question