Solved

take results of select and map it to an insert statement

Posted on 2013-01-03
5
281 Views
Last Modified: 2013-01-03
This is the selection I want:

select into insert
I want insert into table AgentFormList using the SELECT shown above.  Not sure about the syntax.
0
Comment
Question by:knowlton
  • 3
5 Comments
 
LVL 22

Accepted Solution

by:
Steve Wales earned 500 total points
ID: 38741050
insert into AgentFormList
select <rest of your select statement here>
0
 
LVL 5

Author Comment

by:knowlton
ID: 38741113
Yep!


use PP

INSERT INTO [PP].[dbo].[AgentFormList]
           ([AgentFormListSID]
           ,[FormTypeID]
           ,[Sequence]
           ,[FormName]
           ,[ColistFlag]
           ,[AcceptanceReqd]
           ,[DuplicatesAllowed]
           ,[ExternalLink]
           ,[TaskCode]
           ,[AMFID]
           ,[AMFSID]
           ,[ClientID]
           ,[ClientSID]
           ,[ProductID]
           ,[Active])
select
 
      1
      ,[afl].[FormTypeID]
      ,[afl].[Sequence]
      ,[afl].[FormName]
      ,[afl].[ColistFlag]
      ,[afl].[AcceptanceReqd]
      ,[afl].[DuplicatesAllowed]
      ,[afl].[ExternalLink]
      ,[afl].[TaskCode]
      ,[AmFClient].[AMFirmID]
      ,[AmFClient].[AMFirmSID]
      ,[AmFClient].[MerchantID]
      ,[AmFClient].[MerchantSID]
      ,1
      ,1
from agentformlist afl --18*24
cross join (select
              distinct
              Asset.AMFirmID,
              Asset.AMFirmSID,
              Pool.MerchantID,
              Pool.MerchantSID
            from Asset  
            join Pool  on
            Pool.PoolID = Asset.PoolID
            AND Pool.PoolSID = Asset.PoolSID
            ) AS AmFClient
0
 
LVL 5

Author Closing Comment

by:knowlton
ID: 38741114
Thanks!
0
 
LVL 25

Expert Comment

by:TempDBA
ID: 38741119
You can use insert into select combination as expert sjwales suggested above (No points plz)

INSERT INTO TABLENAME (COL1, COL2, COL3, ......, COLN)
SELECT af1.col1,
            af2.col2,
            .
            .
            afn.coln,
            AmFClient.col1,
            AmFClient.col2,
            .
            .
            AmFClient.colm
FROM bla bla bla...

NOTE:- n+m = N
0
 
LVL 5

Author Comment

by:knowlton
ID: 38741132
TempDBA:

Thanks!
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now