Eu tenho uma BD em que as tabelas estão definidas em scripts. Eu gostava de saber como posso gerar as tabelas no Microsoft SQL Server Management Studio 2008?? é que não tem sentido estar a introduzir as tabelas campo a campo quando tenho o script,
agradeço muito a vossa ajuda,
MP
Exemplo de um extracto de script:
use DDS
go
-- Drop FK if exists:
if exists
(select * from sys.foreign_keys
where name = 'fk_fact_campaign_result_dim_customer'
and parent_object_id = object_id('fact_campaign_result'))
alter table fact_campaign_result
drop constraint fk_fact_campaign_result_dim_customer
go
if exists
(select * from sys.foreign_keys
where name = 'fk_fact_communication_subscription_dim_customer'
and parent_object_id = object_id('fact_communication_subscription'))
alter table fact_communication_subscription
drop constraint fk_fact_communication_subscription_dim_customer
go
if exists
(select * from sys.foreign_keys
where name = 'fk_fact_subscription_sales_dim_customer'
and parent_object_id = object_id('fact_subscription_sales'))
alter table fact_subscription_sales
drop constraint fk_fact_subscription_sales_dim_customer
go
if exists
(select * from sys.foreign_keys
where name = 'fk_fact_product_sales_dim_customer'
and parent_object_id = object_id('fact_product_sales'))
alter table fact_product_sales
drop constraint fk_fact_product_sales_dim_customer
Pergunta
marcop
Oi,
Eu tenho uma BD em que as tabelas estão definidas em scripts. Eu gostava de saber como posso gerar as tabelas no Microsoft SQL Server Management Studio 2008?? é que não tem sentido estar a introduzir as tabelas campo a campo quando tenho o script,
agradeço muito a vossa ajuda,
MP
Exemplo de um extracto de script:
use DDS
go
-- Drop FK if exists:
if exists
(select * from sys.foreign_keys
where name = 'fk_fact_campaign_result_dim_customer'
and parent_object_id = object_id('fact_campaign_result'))
alter table fact_campaign_result
drop constraint fk_fact_campaign_result_dim_customer
go
if exists
(select * from sys.foreign_keys
where name = 'fk_fact_communication_subscription_dim_customer'
and parent_object_id = object_id('fact_communication_subscription'))
alter table fact_communication_subscription
drop constraint fk_fact_communication_subscription_dim_customer
go
if exists
(select * from sys.foreign_keys
where name = 'fk_fact_subscription_sales_dim_customer'
and parent_object_id = object_id('fact_subscription_sales'))
alter table fact_subscription_sales
drop constraint fk_fact_subscription_sales_dim_customer
go
if exists
(select * from sys.foreign_keys
where name = 'fk_fact_product_sales_dim_customer'
and parent_object_id = object_id('fact_product_sales'))
alter table fact_product_sales
drop constraint fk_fact_product_sales_dim_customer
go
-- Drop and create the table:
if exists
(select * from sys.tables
where name = 'dim_customer')
drop table dim_customer
go
create table dim_customer
( customer_key int not null
, customer_id varchar(10) not null
, account_number int
, customer_type char(3)
, name varchar(100)
, gender char(1)
, email_address varchar(200)
, date_of_birth datetime
, address1 varchar(50)
, address2 varchar(50)
, address3 varchar(50)
, address4 varchar(50)
....
Link para o comentário
Compartilhar em outros sites
1 resposta a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.