Hi All,

I am new comer in this site. Through Google serach I have found this community. Hope this site is really helpful for the beginers who wants to learn everything

However I have written a query and got the result. Now I want to insert the data (what I have got from the query) into a new table. How will I do that? Here is my query

SELECT  '01220000000FfJfAAK' Record_Type_ID,
    'Information Age Subscription' Opportunity_Type,                    
    'Information Age Subscription' Product_Name,
    status_active_inactive Active_Inactive__c,
    source LeadSource,
        CASE    WHEN publication = 'IA'     THEN    'Paper based'
                WHEN publication = 'Web'    THEN    'Web based'
    ) Publication_Type__c, 
    amount_paid Amount, 
    record_creation_date_subscriptions CloseDate,                       
    'Closed Won' StageName,                                             
    Status status_c, 
    subscription_qual_date Subscription_Qualification_Date__c, 
    date_cancelled Date_Cancelled__c, 
    reason_cancelled Reason_Cancelled__c, 
    date_suspended Date_Suspended__c, 
    reason_suspended Reason_Suspended__c, 
    date_expired Date_Expired__c, 
    reason_expired Reason_Expired__c, 
    Type Subscription_Type2__c, 
    'Time Based' Type,                          
    start_issue_date Subscription_Start_Date__c, 
    term Term__C, 
    date_expired Subscription_End_Date__c, 
    BPA_PIQ_Question BPA_PIQ_Question__c, 
    BPA_PIQ_Answer BPA_PIQ_Answer__c, 
    IA_IAA IA_IAA__c, 
    IA_IAB IA_IAB__c 
FROM dbo.IASubscription

I hope u will help me out

Recommended Answers

All 2 Replies

If the new table matches the output of the query, you can just use INSERT INTO newtable SELECT ...

If you want to create a brand-new table from the results of your select, you can use this syntax:

INTO dbo.myNewTable
FROM dbo.IASubscription

The drawback with this approach is that sometimes the datatypes you wind up with may not be the ones you would choose if you just created the table, then used @pritaeas' suggestion.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.