Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

take results of select and map it to an insert statement

Posted on 2013-01-03
5
Medium Priority
?
288 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:Tom Knowlton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 23

Accepted Solution

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

Author Comment

by:Tom 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:Tom 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:Tom Knowlton
ID: 38741132
TempDBA:

Thanks!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
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…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

715 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