IF (EXISTS(select * from sys.systable as T where LCase(T.table_name) = LCase('RoomStatusForPeriod'))) THEN drop table RoomStatusForPeriod END IF GO create table RoomStatusForPeriod( "N" integer not null default autoincrement, "NRoom" integer not null, "NStatus" integer not null, "StartDate" date not null, "EndDate" date not null, "Komentar" varchar(250), primary key("N") ) GO alter table RoomStatusForPeriod add foreign key "FK_Room" ("NRoom") references "dba"."Rooms"("RoomNum") GO alter table RoomStatusForPeriod add foreign key "FK_Status" ("NStatus") references "dba"."RoomStatus"("RoomStatusNo")