Click here to Skip to main content
15,905,148 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more: , +
How to select and insert in one query using Different Tables in sql server?
Posted

Is this what you are attempting to do?
INSERT INTO [Records].[dbo].[ARCHIVE]
SELECT * FROM [Records].[dbo].[CURRENT]
 
Share this answer
 
v2
Try to use T-SQL blocks, have look here. see example G.
 
Share this answer
 
Finally i used the below Statement.. It is working well..

SQL
INSERT INTO InsCarriers_Copy
                                (   InsCarrierId,
                                    InsCarrierName,
                                    ShortDescription,
                                    ContactPhoneNo,
                                    Location,
                                    PhoneExt,
                                    Fax,
                                    Address1,
                                    Address2,
                                    ZipCode,
                                    City,
                                    State,
                                    IsActive
                                )
SELECT      InsCarrierId,
            InsCarrierName,
            ShortDescription,
            ContactPhoneNo,
            Location,
            PhoneExt,
            Fax,
            Address1,
            Address2,
            ZipCode,
            City,
            [State],
            IsActive
FROM        InsCarriers
 
Share this answer
 
v2
You need to use link server concept for this. google this ..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900