Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Script From Oracle To SQL Server

Avatar of ralph_rea
ralph_rea asked on
Microsoft SQL ServerOracle DatabaseMicrosoft SQL Server 2005
12 Comments1 Solution422 ViewsLast Modified:
Hi,
I've this Oracle script:

-- create table SITE
CREATE TABLE SITE
(
  NAME                VARCHAR2(32 BYTE)         DEFAULT NULL,
  SITE_ID             VARCHAR2(16 BYTE)         DEFAULT NULL                  NOT NULL
);

ALTER TABLE SITE ADD (
  CONSTRAINT SITE_PK
 PRIMARY KEY
 (SITE_ID);
 
-- create table BL
CREATE TABLE BL
(
  NAME                VARCHAR2(25 BYTE)         DEFAULT NULL,
  SITE_ID             VARCHAR2(16 BYTE)         DEFAULT NULL,
  BL_ID               VARCHAR2(8 BYTE)          DEFAULT NULL                  NOT NULL
);
 
ALTER TABLE BL ADD (
  CONSTRAINT BL_PK
 PRIMARY KEY
 (BL_ID);
 
 ALTER TABLE BL ADD (
  CONSTRAINT BL_SITE_ID
 FOREIGN KEY (SITE_ID)
 REFERENCES SITE (SITE_ID));
 
-- create table FL
CREATE TABLE FL
(
  NAME                VARCHAR2(25 BYTE)         DEFAULT NULL,
  BL_ID               VARCHAR2(8 BYTE)          DEFAULT NULL                  NOT NULL,
  FL_ID               VARCHAR2(4 BYTE)          DEFAULT NULL                  NOT NULL
);

ALTER TABLE FL ADD (
  CONSTRAINT FL_PK
 PRIMARY KEY
 (BL_ID, FL_ID);
 

ALTER TABLE FL ADD (
  CONSTRAINT FL_BL_ID
 FOREIGN KEY (BL_ID)
 REFERENCES BL (BL_ID));
 

-- create table RM
CREATE TABLE RM
(
  NAME             VARCHAR2(16 BYTE)            DEFAULT NULL,
  BL_ID            VARCHAR2(8 BYTE)             DEFAULT NULL                  NOT NULL,
  FL_ID            VARCHAR2(4 BYTE)             DEFAULT NULL                  NOT NULL,
  RM_ID            VARCHAR2(8 BYTE)             DEFAULT NULL                  NOT NULL
);

ALTER TABLE RM ADD (
  CONSTRAINT RM_PK
 PRIMARY KEY
 (BL_ID, FL_ID, RM_ID),
 
ALTER TABLE RM ADD (
  CONSTRAINT RM_BL_ID
 FOREIGN KEY (BL_ID)
 REFERENCES BL (BL_ID));
 
ALTER TABLE RM ADD (
  CONSTRAINT RM_FL_ID
 FOREIGN KEY (BL_ID, FL_ID)
 REFERENCES FL (BL_ID,FL_ID));
 

I'd like to write the same script for SQL Server 2005

Have you any idea?