Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2010
    Location
    Norway
    Posts
    45

    Unanswered: Hello - Export data from one catalog1-table1 to a catalog2-table2

    Hello

    I have two user tables, one is in a catalog1 another is in catalog2.
    How would I copy catalog1.users into catalog2.users (not duplicate, but copy some fields over...).

    I've tried variations of thi sample code below, with #temptable and with @temptable, inside the "use master" and outside of....

    Code:
    USE master 
    DECLARE @temptable TABLE (name nvarchar(5))
    
    USE [Users]
    GO
    INSERT INTO @temptable(name)
    (
    	SELECT name FROM users
    )
    
    USE [Catalog2]
    GO
    INSERT INTO dbo.users(name)
    (
    	SELECT name from @temptable
    )
    SQL 2008, R2.
    Suggestions are more than welcome.

    Edit: Oh, maybe I can just insert it straight into the table, something like this:
    Code:
    INSERT INTO catalog2.users(name)
    VALUES
    ( 
     SELECT name FROM catalog1.users
    )
    Edit: Solved, worked like a charm, no need for the temporary table... Thanks for your time!
    Edit: Refined the question a bit.
    Last edited by ManyTimes; 07-10-13 at 07:16.

  2. #2
    Join Date
    Aug 2004
    Location
    Dallas, Texas
    Posts
    831
    My time was reading your problem and subsequent solution.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •