Solved

take results of select and map it to an insert statement

Posted on 2013-01-03
5
283 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

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…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

805 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