Results 1 to 3 of 3

Thread: How to move table from one databse to other database

  1. #1
    Join Date
    Jul 2003
    Posts
    421

    How to move table from one databse to other database

    Hi all,
    I wan to move tables from one databse to other dataabse , how to do that??
    my folllowin gcode is not worke fine

    drop table Sec06
    go
    create table Sec06
    (
    MyNumber int not null identity(1,1) primary key,
    NewNum as '06-' + convert(varchar(10), MyNumber),
    Name varchar(50) not null,
    Segment Varchar(10) not null,
    Sequence varchar(7500) not null,
    length varchar(10) not null,
    SubType varchar(10) not Null,
    location varchar(10) not Null,
    SampleYear varchar(10) not Null,
    author varchar(10) not Null
    references dbo.pubs.users(Name))
    what mistake I make??
    ________
    X4
    Last edited by sql; 03-06-2011 at 01:42 AM.

  2. #2
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    Lets say you have two database DB1 and DB2
    use db2
    go
    create table a1(id int, name varchar(100)) --Your create table statement goes here

    go
    insert into a1(id,name) select id,name from db1.dbo.a1
    go
    use db1
    go
    --drop table a1


    Your statement has Cross-database foreign key references which is not supported in SQL Server.

  3. #3
    Join Date
    Jul 2003
    Posts
    421
    Hi mak,
    Thank you every much, I forgot every thing. I make a mistake at dbo. dB1.table.
    Thank you every much.
    ________
    Buy easy vape
    Last edited by sql; 03-06-2011 at 01:42 AM.

Posting Permissions

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