Solved

take results of select and map it to an insert statement

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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
check the deletion of SQL job on who delete/disable it 12 29
MSSQL: Replace text (typo) 7 34
SQL Server stored proc 2 14
Adding Subtracting values in sql server 5 21
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
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…

863 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

22 Experts available now in Live!

Get 1:1 Help Now