Hello, I have one set of tables (AMembers, AOrders) and have reference,
constrains between them.
How to make a copy of to (BMembers, BOrders) or (CMembers, COrders)? Please
advance.Take a look at select/into in book online. You should be able to create a
new table with/out data with the same schema as the original table.
-oj
"js" <js@.someone@.hotmail.com> wrote in message
news:uYOuwpFQFHA.1476@.TK2MSFTNGP09.phx.gbl...
> Hello, I have one set of tables (AMembers, AOrders) and have reference,
> constrains between them.
> How to make a copy of to (BMembers, BOrders) or (CMembers, COrders)?
> Please advance.
>|||Here you go..
use northwind
go
create table table1 (
colA int not null primary key,
colB int null,
colC int null
)
go
insert table1 values(1,33,44)
insert table1 values(2,55,66)
insert table1 values(3,77,88)
select * into table2 from table1
print 'selecting from table2'
select * from table2
drop table table1
drop table table2
go
HTH
ZULFIQAR SYED
"oj" wrote:
> Take a look at select/into in book online. You should be able to create a
> new table with/out data with the same schema as the original table.
> --
> -oj
>
> "js" <js@.someone@.hotmail.com> wrote in message
> news:uYOuwpFQFHA.1476@.TK2MSFTNGP09.phx.gbl...
>
>|||Thanks oj,
I created some identical tables, but how to maintain the reference and
enforce relationship for cascade update options...
"oj" <nospam_ojngo@.home.com> wrote in message
news:eUG8tbIQFHA.3156@.TK2MSFTNGP15.phx.gbl...
> Take a look at select/into in book online. You should be able to create a
> new table with/out data with the same schema as the original table.
> --
> -oj
>
> "js" <js@.someone@.hotmail.com> wrote in message
> news:uYOuwpFQFHA.1476@.TK2MSFTNGP09.phx.gbl...
>|||Hi oj,
No good, only the schema is transferred. All the primary key, and default
value and reference are missing.
Is it a good way to handle this_
"oj" <nospam_ojngo@.home.com> wrote in message
news:eUG8tbIQFHA.3156@.TK2MSFTNGP15.phx.gbl...
> Take a look at select/into in book online. You should be able to create a
> new table with/out data with the same schema as the original table.
> --
> -oj
>
> "js" <js@.someone@.hotmail.com> wrote in message
> news:uYOuwpFQFHA.1476@.TK2MSFTNGP09.phx.gbl...
>|||If you want the system to do it for you, you can use DTS and be sure to
select all those dependencies for the table.
If you want to do it yourself (a good way to learn about the system) you
would want to use QA/EM to generate the DDL for the base table. Again, be
sure to include all those dependencies. Then you just modify the script to
change the name of the base table to your new one and execute the script to
create the new table.
select/into will only transfer schema with/out data. Dependencies are never
part of it. Sorry, if I've misled you.
-oj
"js" <js@.someone@.hotmail.com> wrote in message
news:O7dXSSQQFHA.4028@.tk2msftngp13.phx.gbl...
> Hi oj,
> No good, only the schema is transferred. All the primary key, and default
> value and reference are missing.
>
> Is it a good way to handle this_
>
> "oj" <nospam_ojngo@.home.com> wrote in message
> news:eUG8tbIQFHA.3156@.TK2MSFTNGP15.phx.gbl...
>|||thanks oj,
I already have the table schema, is it a good way to find out the diff
between the old, new table(dependencies)...? or have to compare the DDL by
myself...
"oj" <nospam_ojngo@.home.com> wrote in message
news:%23Gme6kQQFHA.3196@.TK2MSFTNGP12.phx.gbl...
> If you want the system to do it for you, you can use DTS and be sure to
> select all those dependencies for the table.
> If you want to do it yourself (a good way to learn about the system) you
> would want to use QA/EM to generate the DDL for the base table. Again, be
> sure to include all those dependencies. Then you just modify the script to
> change the name of the base table to your new one and execute the script
> to create the new table.
> select/into will only transfer schema with/out data. Dependencies are
> never part of it. Sorry, if I've misled you.
> --
> -oj
> "js" <js@.someone@.hotmail.com> wrote in message
> news:O7dXSSQQFHA.4028@.tk2msftngp13.phx.gbl...
>|||I'm trying the DDL, which option is for the dependencies? Please advice
"oj" <nospam_ojngo@.home.com> wrote in message
news:%23Gme6kQQFHA.3196@.TK2MSFTNGP12.phx.gbl...
> If you want the system to do it for you, you can use DTS and be sure to
> select all those dependencies for the table.
> If you want to do it yourself (a good way to learn about the system) you
> would want to use QA/EM to generate the DDL for the base table. Again, be
> sure to include all those dependencies. Then you just modify the script to
> change the name of the base table to your new one and execute the script
> to create the new table.
> select/into will only transfer schema with/out data. Dependencies are
> never part of it. Sorry, if I've misled you.
> --
> -oj
> "js" <js@.someone@.hotmail.com> wrote in message
> news:O7dXSSQQFHA.4028@.tk2msftngp13.phx.gbl...
>|||For QA, under Tools -> Options -> Script or Scripting Tools options.
For EM, under All tasks -> Generate SQL script-> Formatting
-oj
"js" <js@.someone@.hotmail.com> wrote in message
news:OnXv4zQQFHA.3336@.TK2MSFTNGP09.phx.gbl...
> I'm trying the DDL, which option is for the dependencies? Please advice
> "oj" <nospam_ojngo@.home.com> wrote in message
> news:%23Gme6kQQFHA.3196@.TK2MSFTNGP12.phx.gbl...
>|||Thanks oj,
When I run the DDL to copy the tables, got lots of error:
There is already an object named 'PK_CustTrx' in the database.
Should I rename the PK_CustTrx name? Please advice.
"oj" <nospam_ojngo@.home.com> wrote in message
news:%238HTOLTQFHA.2136@.TK2MSFTNGP14.phx.gbl...
> For QA, under Tools -> Options -> Script or Scripting Tools options.
> For EM, under All tasks -> Generate SQL script-> Formatting
> --
> -oj
>
> "js" <js@.someone@.hotmail.com> wrote in message
> news:OnXv4zQQFHA.3336@.TK2MSFTNGP09.phx.gbl...
>
No comments:
Post a Comment