Sunday, March 11, 2012

add table from one DB into another DB on same sql server

Hi
Is there an easy way to add table from one database into another database on
the same sql server 2000?
e.g DB1 .....Table1, Table2...
add Table1, Table2... into DB2
Thank you.
ShaileshUSE DB2
CREATE TABLE dbo.Table1 (...)
CREATE TABLE dbo.Table2 (...)
INSERT INTO dbo.Table1 (...)
SELECT ...
FROM DB1.dbo.Table1
INSERT INTO dbo.Table2 (...)
SELECT ...
FROM DB1.dbo.Table2
David Portas
SQL Server MVP
--|||Use INSERT ... SELECT ...
Example:
use db1
go
insert into t (col1, col2, ...)
select col1, col2, ... from db2..t
go
AMB
"Shailesh Patel" wrote:

> Hi
> Is there an easy way to add table from one database into another database
on
> the same sql server 2000?
> e.g DB1 .....Table1, Table2...
> add Table1, Table2... into DB2
> Thank you.
> Shailesh
>
>|||If the table does not exists in the targer db, then use SELECT ... INTO ...
Example:
use db1
go
select col1, col2, ...
into db2..t
from t
go
No constraints, relations, indexes will be created.
AMB
"Alejandro Mesa" wrote:
> Use INSERT ... SELECT ...
> Example:
> use db1
> go
> insert into t (col1, col2, ...)
> select col1, col2, ... from db2..t
> go
>
> AMB
>
> "Shailesh Patel" wrote:
>|||note: SELECT ... INTO ... doesn't work unless the select into/bulkcopy optio
n
is set on the database. It should be emphasized that this option interferes
with some database recovery models, and thus should be avoided in a
production environment. Your original reply was the better solution.
"Alejandro Mesa" wrote:
> If the table does not exists in the targer db, then use SELECT ... INTO ..
.
> Example:
> use db1
> go
> select col1, col2, ...
> into db2..t
> from t
> go
> No constraints, relations, indexes will be created.
>
> AMB
>
> "Alejandro Mesa" wrote:
>|||'select into/bulkcopy' option is no longer needed in sql2k. Take a quick
look at the [INTO] section.
http://msdn.microsoft.com/library/e...sa-ses_9sfo.asp
-oj
"Brian Selzer" <BrianSelzer@.discussions.microsoft.com> wrote in message
news:C88C3B63-C3EE-4FFE-B9FC-3B24D1FCDB39@.microsoft.com...
> note: SELECT ... INTO ... doesn't work unless the select into/bulkcopy
> option
> is set on the database. It should be emphasized that this option
> interferes
> with some database recovery models, and thus should be avoided in a
> production environment. Your original reply was the better solution.
>
> "Alejandro Mesa" wrote:
>|||Thank you for clarifying that.
"oj" wrote:

> 'select into/bulkcopy' option is no longer needed in sql2k. Take a quick
> look at the [INTO] section.
> http://msdn.microsoft.com/library/e...sa-ses_9sfo.asp
>
> --
> -oj
>
> "Brian Selzer" <BrianSelzer@.discussions.microsoft.com> wrote in message
> news:C88C3B63-C3EE-4FFE-B9FC-3B24D1FCDB39@.microsoft.com...
>
>

No comments:

Post a Comment