Hello
I have a tabel in catalog "dbo.Users" and a table named "users" that I want to copy some fields from the "users" table into a different catalog, say "dbo.Catalog" and the table "users" in the dbo.Catalog.
So, something along these lines (I've tried multiple variations of this, temporary template, or #temptable and defining the temporary table outside...etc..
SQL 2008, R2.
Suggestions are more than welcome.
Edit: Oh, maybe I can just insert it straigth into the table, something like this:
INSERT INTO Catalog.newUserTable (name)
VALUES
(
SELECT name FROM Users.user
)
Edit: Solved, worked like a charm, no need for the temporary table... Thanks for your time!
I have a tabel in catalog "dbo.Users" and a table named "users" that I want to copy some fields from the "users" table into a different catalog, say "dbo.Catalog" and the table "users" in the dbo.Catalog.
So, something along these lines (I've tried multiple variations of this, temporary template, or #temptable and defining the temporary table outside...etc..
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
)
Suggestions are more than welcome.
Edit: Oh, maybe I can just insert it straigth into the table, something like this:
INSERT INTO Catalog.newUserTable (name)
VALUES
(
SELECT name FROM Users.user
)
Edit: Solved, worked like a charm, no need for the temporary table... Thanks for your time!