home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1999-05-24 | 56.1 KB | 1,766 lines
GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='this_server')>0 DROP DEFAULT dbo.this_server GO CREATE DEFAULT this_server AS @@servername GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='_version')>0 DROP TABLE _version GO CREATE TABLE version ( version int NULL, revision int NULL ) PRINT 'Creating table workdb4' GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='_workdb4')>0 DROP TABLE _workdb4 GO CREATE TABLE workdb4 ( name sysname NOT NULL, sourcedb sysname NOT NULL, status int NULL, dt_downsize datetime NULL, s_who varchar(255) NULL, CONSTRAINT PK__workdb4__0EA330E9 PRIMARY KEY CLUSTERED (name) ) PRINT 'Creating table view_item4' GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='_view_item4')>0 DROP TABLE _view_item4 GO CREATE TABLE view_item4 ( id int NULL, tbl sysname NULL, vx int NULL, vy int NULL, cx int NULL, cy int NULL, flags int NULL, cmt_usr sysname NULL, cmt_txt text NULL ) PRINT 'Creating table options' GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='_options')>0 DROP TABLE _options GO CREATE TABLE options ( opt_name varchar(255) NOT NULL, opt_text varchar(255) NULL, opt_int int NULL, last_update varchar(30) NULL, CONSTRAINT PK__options__1B0907CE PRIMARY KEY CLUSTERED (opt_name) ) GO GRANT SELECT ON options TO public GO PRINT 'Creating table orderby' GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='_orderby')>0 DROP TABLE _orderby GO CREATE TABLE orderby ( report_id int NOT NULL, orderby_id int NOT NULL, attribute_id int NULL, b_desc bit NOT NULL, CONSTRAINT PK__orderby__1ED998B2 PRIMARY KEY NONCLUSTERED (report_id, orderby_id) ) GO GRANT SELECT ON orderby TO public GO PRINT 'Creating table graph' GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='_graph')>0 DROP TABLE _graph GO CREATE TABLE graph ( report_id int NOT NULL, graph_id int NOT NULL, name varchar(255) NULL, graphtype int NULL, c_surx int NULL, c_sury int NULL, c_surz int NULL, c_bk int NULL, c_graph int NULL, c_palettestart int NULL, c_paletteend int NULL, c_text int NULL, c_podlozka int NULL, lwidth int NULL, bold_r int NULL, dec_dig int NULL, pier float NULL, transparent float NULL, light_intensity float NULL, flags int NULL, rot_a float NULL, rot_b float NULL, rot_c float NULL, nscolid int NULL, c_wall1 int NULL, c_wall2 int NULL, c_wall3 int NULL, bar3d_type int NULL, col int NULL, lfHeight int NULL, lfFlags int NULL, lfPitchAndFamily tinyint NULL, lfFaceName varchar(32) NULL, reserved float NULL, glHeight int NULL, glFlags int NULL, glPitchAndFamily int NULL, glFaceName varchar(32) NULL, CONSTRAINT PK__graph__20C1E124 PRIMARY KEY NONCLUSTERED (report_id, graph_id) ) GO --GRANT REFERENCES ON graph TO public GO GRANT SELECT ON graph TO public GO --GRANT INSERT ON graph TO public GO --GRANT DELETE ON graph TO public GO --GRANT UPDATE ON graph TO public PRINT 'Creating table keys' GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='_keys')>0 DROP TABLE _keys GO CREATE TABLE keys ( object_id int NOT NULL, object_depid int NOT NULL, key_id int NOT NULL, flags int NOT NULL, key1 int NULL, key2 int NULL, key3 int NULL, key4 int NULL, key5 int NULL, key6 int NULL, key7 int NULL, key8 int NULL, depkey1 int NULL, depkey2 int NULL, depkey3 int NULL, depkey4 int NULL, depkey5 int NULL, depkey6 int NULL, depkey7 int NULL, depkey8 int NULL, CONSTRAINT PK__keys__22AA2996 PRIMARY KEY NONCLUSTERED (object_id, object_depid, key_id) ) GO --GRANT REFERENCES ON keys TO public GO GRANT SELECT ON keys TO public GO --GRANT INSERT ON keys TO public GO --GRANT DELETE ON keys TO public GO --GRANT UPDATE ON keys TO public PRINT 'Creating table object' GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='_object')>0 DROP TABLE _object GO CREATE TABLE object ( object_id int NOT NULL, report_id int NOT NULL, type int NOT NULL, table_name varchar(255) NOT NULL, alias_name sysname NULL, flags int NOT NULL, vx int NOT NULL, vy int NOT NULL, cx int NOT NULL, cy int NOT NULL, index_used varchar(32) NULL, set_name sysname NULL, CONSTRAINT PK__object__29572725 PRIMARY KEY NONCLUSTERED (object_id) ) GO --GRANT REFERENCES ON object TO public GO GRANT SELECT ON object TO public GO --GRANT INSERT ON object TO public GO --GRANT DELETE ON object TO public GO --GRANT UPDATE ON object TO public PRINT 'Creating table param' GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='_param')>0 DROP TABLE _param GO CREATE TABLE param ( report_id int NOT NULL, set_name sysname NOT NULL, name sysname NOT NULL, value varchar(255) NOT NULL ) GO --GRANT REFERENCES ON param TO public GO GRANT SELECT ON param TO public GO --GRANT INSERT ON param TO public GO --GRANT DELETE ON param TO public GO --GRANT UPDATE ON param TO public PRINT 'Creating table graph_pos' GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='_graph_pos')>0 DROP TABLE _graph_pos GO CREATE TABLE graph_pos ( report_id int NULL, graph_id int NULL, ord int NULL, x int NULL, y int NULL ) GO --GRANT REFERENCES ON graph_pos TO public GO GRANT SELECT ON graph_pos TO public GO --GRANT INSERT ON graph_pos TO public GO --GRANT DELETE ON graph_pos TO public GO --GRANT UPDATE ON graph_pos TO public PRINT 'Creating table graph_attribute' GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='_graph_attribute')>0 DROP TABLE _graph_attribute GO CREATE TABLE graph_attribute ( report_id int NOT NULL, graph_id int NOT NULL, colid int NOT NULL, ord int NOT NULL ) GO --GRANT REFERENCES ON graph_attribute TO public GO GRANT SELECT ON graph_attribute TO public GO --GRANT INSERT ON graph_attribute TO public GO --GRANT DELETE ON graph_attribute TO public GO --GRANT UPDATE ON graph_attribute TO public PRINT 'Creating table graph_color' GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='_graph_color')>0 DROP TABLE _graph_color GO CREATE TABLE graph_color ( report_id int NOT NULL, graph_id int NOT NULL, ord int NOT NULL, color int NOT NULL, CONSTRAINT PK__graph_color__2E1BDC42 PRIMARY KEY NONCLUSTERED (report_id, graph_id, ord) ) GO --GRANT REFERENCES ON graph_color TO public GO GRANT SELECT ON graph_color TO public GO --GRANT INSERT ON graph_color TO public GO --GRANT DELETE ON graph_color TO public GO --GRANT UPDATE ON graph_color TO public PRINT 'Creating table layout' GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='_layout')>0 DROP TABLE _layout GO CREATE TABLE layout ( report_id int NOT NULL, flags int NULL, m_head int NULL, m_top int NULL, m_bottom int NULL, m_foot int NULL, m_left int NULL, m_right int NULL, t_head text NULL, t_foot text NULL, hHeight int NULL, hFlags int NULL, hPitchAndFamily tinyint NULL, hFaceName varchar(32) NULL, rHeight int NULL, rFlags int NULL, rPitchAndFamily tinyint NULL, rFaceName varchar(32) NULL, h0Height int NULL, h0Flags int NULL, h0PitchAndFamily tinyint NULL, h0FaceName varchar(32) NULL, h1Height int NULL, h1Flags int NULL, h1PitchAndFamily tinyint NULL, h1FaceName varchar(32) NULL, h2Height int NULL, h2Flags int NULL, h2PitchAndFamily tinyint NULL, h2FaceName varchar(32) NULL, f0Height int NULL, f0Flags int NULL, f0PitchAndFamily tinyint NULL, f0FaceName varchar(32) NULL, f1Height int NULL, f1Flags int NULL, f1PitchAndFamily tinyint NULL, f1FaceName varchar(32) NULL, f2Height int NULL, f2Flags int NULL, f2PitchAndFamily tinyint NULL, f2FaceName varchar(32) NULL, CONSTRAINT PK__layout__300424B4 PRIMARY KEY NONCLUSTERED (report_id) ) GO --GRANT REFERENCES ON layout TO public GO GRANT SELECT ON layout TO public GO --GRANT INSERT ON layout TO public GO --GRANT DELETE ON layout TO public GO --GRANT UPDATE ON layout TO public PRINT 'Creating table attribute' GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='_attribute')>0 DROP TABLE _attribute GO CREATE TABLE attribute ( report_id int NOT NULL, attribute_id int NOT NULL, object_id int NULL, obj_attr_name varchar(255) NOT NULL, name varchar(255) NULL, is_null varchar(255) NULL, agregate int NOT NULL, align int NOT NULL, flags int NOT NULL, texcp int NOT NULL, texcp_val int NULL, bexcp int NOT NULL, bexcp_val int NULL, colid int NULL, CONSTRAINT PK__attribute__31EC6D26 PRIMARY KEY NONCLUSTERED (report_id, attribute_id) ) GO --GRANT REFERENCES ON attribute TO public GO GRANT SELECT ON attribute TO public GO --GRANT INSERT ON attribute TO public GO --GRANT DELETE ON attribute TO public GO --GRANT UPDATE ON attribute TO public PRINT 'Creating table ptree' GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='_ptree')>0 DROP TABLE _ptree GO CREATE TABLE ptree ( db sysname NOT NULL, parent sysname NOT NULL, child sysname NULL, ch_type int NOT NULL ) GO --GRANT REFERENCES ON ptree TO public GO GRANT SELECT ON ptree TO public GO --GRANT INSERT ON ptree TO public GO --GRANT DELETE ON ptree TO public GO --GRANT UPDATE ON ptree TO public PRINT 'Creating table report_error' GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='_report_error')>0 DROP TABLE _report_error GO CREATE TABLE report_error ( report_id int NULL, d_time datetime NULL, usr varchar(30) NULL, s_message text NULL ) GO --GRANT REFERENCES ON report_error TO public GO GRANT SELECT ON report_error TO public GO --GRANT INSERT ON report_error TO public GO --GRANT DELETE ON report_error TO public GO --GRANT UPDATE ON report_error TO public PRINT 'Creating table conspects5' GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='_conspects5')>0 DROP TABLE _conspects5 GO CREATE TABLE conspects5 ( server sysname NOT NULL, db sysname NOT NULL, tbl sysname NOT NULL, colid int NOT NULL, comment varchar(255) NULL, CONSTRAINT PK__conspects5__52593CB8 PRIMARY KEY CLUSTERED (server, db, tbl, colid) ) GO sp_bindefault this_server, 'conspects5.server' GO --GRANT REFERENCES ON conspects5 TO public GO GRANT SELECT ON conspects5 TO public GO --GRANT INSERT ON conspects5 TO public GO --GRANT DELETE ON conspects5 TO public GO --GRANT UPDATE ON conspects5 TO public PRINT 'Creating table notes5' GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='_notes5')>0 DROP TABLE _notes5 GO CREATE TABLE notes5 ( server sysname NOT NULL, db sysname NOT NULL, tbl sysname NOT NULL, whr varchar(255) NULL, usr sysname NOT NULL, comment text NULL ) GO sp_bindefault this_server, 'notes5.server' GO --GRANT REFERENCES ON notes5 TO public GO GRANT SELECT ON notes5 TO public GO --GRANT INSERT ON notes5 TO public GO --GRANT DELETE ON notes5 TO public GO --GRANT UPDATE ON notes5 TO public PRINT 'Creating table rel5' GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='_rel5')>0 DROP TABLE _rel5 GO CREATE TABLE rel5 ( server sysname NOT NULL, db sysname NOT NULL, tbl sysname NOT NULL, vx int NULL, vy int NULL, cx int NULL, cy int NULL, flags int NULL, CONSTRAINT PK__rel5__5535A963 PRIMARY KEY CLUSTERED (server, db, tbl) ) GO sp_bindefault this_server, 'rel5.server' GO --GRANT REFERENCES ON rel5 TO public GO GRANT SELECT ON rel5 TO public GO --GRANT INSERT ON rel5 TO public GO --GRANT DELETE ON rel5 TO public GO --GRANT UPDATE ON rel5 TO public PRINT 'Creating table keysadd5' GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='_keysadd5')>0 DROP TABLE _keysadd5 GO CREATE TABLE keysadd5 ( server sysname NOT NULL, db sysname NULL, id sysname NULL, depid sysname NULL, flags int NULL, str varchar(255) NULL, key1 int NULL, key2 int NULL, key3 int NULL, key4 int NULL, key5 int NULL, key6 int NULL, key7 int NULL, key8 int NULL, key9 int NULL, key10 int NULL, key11 int NULL, key12 int NULL, key13 int NULL, key14 int NULL, key15 int NULL, key16 int NULL ) GO sp_bindefault this_server, 'keysadd5.server' GO --GRANT REFERENCES ON keysadd5 TO public GO GRANT SELECT ON keysadd5 TO public GO --GRANT INSERT ON keysadd5 TO public GO --GRANT DELETE ON keysadd5 TO public GO --GRANT UPDATE ON keysadd5 TO public PRINT 'Creating table patriklog5' GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='_patriklog5')>0 DROP TABLE _patriklog5 GO CREATE TABLE patriklog5 ( server sysname NOT NULL, db sysname NOT NULL, tbl sysname NOT NULL, flags int NULL, CONSTRAINT PK__patriklog5__5812160E PRIMARY KEY CLUSTERED (server, db, tbl) ) GO sp_bindefault this_server, 'patriklog5.server' GO --GRANT REFERENCES ON patriklog5 TO public GO GRANT SELECT ON patriklog5 TO public GO --GRANT INSERT ON patriklog5 TO public GO --GRANT DELETE ON patriklog5 TO public GO --GRANT UPDATE ON patriklog5 TO public PRINT 'Creating table rel_view5' GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='_rel_view5')>0 DROP TABLE _rel_view5 GO CREATE TABLE rel_view5 ( server sysname NOT NULL, id int NULL, name sysname NULL, db sysname NULL, usr sysname NULL ) GO sp_bindefault this_server, 'rel_view5.server' GO --GRANT REFERENCES ON rel_view5 TO public GO GRANT SELECT ON rel_view5 TO public GO --GRANT INSERT ON rel_view5 TO public GO --GRANT DELETE ON rel_view5 TO public GO --GRANT UPDATE ON rel_view5 TO public PRINT 'Creating table report5' GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='_report5')>0 DROP TABLE _report5 GO CREATE TABLE report5 ( report_id int NOT NULL, server sysname NOT NULL, db sysname NOT NULL, name sysname NULL, description varchar(255) NULL, flags int NOT NULL DEFAULT (0), sample_lines int NOT NULL DEFAULT (10), rel_flags int NOT NULL, rel_x int NOT NULL, rel_y int NOT NULL, last_changed varchar(32) NULL, s_select text NULL, rel_scale int NULL, s_where text NULL, prolog_procedure varchar(255) NULL, epilog_procedure varchar(255) NULL, lt_locker datetime NULL, CONSTRAINT PK__report5__5AEE82B9 PRIMARY KEY CLUSTERED (report_id), CONSTRAINT UQ__report5__5BE2A6F2 UNIQUE NONCLUSTERED (server, db) ) GO sp_bindefault this_server, 'report5.server' GO --GRANT REFERENCES ON report5 TO public GO GRANT SELECT ON report5 TO public GO --GRANT INSERT ON report5 TO public GO --GRANT DELETE ON report5 TO public GO --GRANT UPDATE ON report5 TO public PRINT 'Creating table md_def5' GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='_md_def5')>0 DROP TABLE _md_def5 GO CREATE TABLE md_def5 ( server sysname NOT NULL, db sysname NOT NULL, feature varchar(255) NOT NULL, width int NULL, ord int NOT NULL, b_history tinyint NULL, CONSTRAINT PK__md_def5__5FB337D6 PRIMARY KEY CLUSTERED (server, db, ord) ) GO sp_bindefault this_server, 'md_def5.server' GO --GRANT REFERENCES ON md_def5 TO public GO GRANT SELECT ON md_def5 TO public GO --GRANT INSERT ON md_def5 TO public GO --GRANT DELETE ON md_def5 TO public GO --GRANT UPDATE ON md_def5 TO public PRINT 'Creating table md_data5' GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='_md_data5')>0 DROP TABLE _md_data5 GO CREATE TABLE md_data5 ( server sysname NOT NULL, db sysname NOT NULL, tbl sysname NOT NULL, colid int NOT NULL, data text NOT NULL, CONSTRAINT PK__md_data5__619B8048 PRIMARY KEY CLUSTERED (server, db, tbl, colid) ) GO sp_bindefault this_server, 'md_data5.server' GO --GRANT REFERENCES ON md_data5 TO public GO GRANT SELECT ON md_data5 TO public GO --GRANT INSERT ON md_data5 TO public GO --GRANT DELETE ON md_data5 TO public GO --GRANT UPDATE ON md_data5 TO public PRINT 'Creating table md_history5' GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='_md_history5')>0 DROP TABLE _md_history5 GO CREATE TABLE md_history5 ( server sysname NOT NULL, db sysname NOT NULL, tbl sysname NOT NULL, colid int NOT NULL, feature_ord int NOT NULL, d_change datetime NOT NULL, data text NULL, usr varchar(65) NOT NULL ) GO sp_bindefault this_server, 'md_history5.server' GO --GRANT REFERENCES ON md_history5 TO public GO GRANT SELECT ON md_history5 TO public GO --GRANT INSERT ON md_history5 TO public GO --GRANT DELETE ON md_history5 TO public GO ----GRANT UPDATE ON md_history5 TO public PRINT 'Creating table tabexpand5' GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='_tabexpand5')>0 DROP TABLE _tabexpand5 GO CREATE TABLE tabexpand5 ( server sysname NOT NULL, usr sysname NOT NULL, db sysname NOT NULL, tbl sysname NOT NULL, op int NOT NULL, colid int NULL, arg varchar(255) NULL ) GO sp_bindefault this_server, 'tabexpand5.server' GO PRINT 'Transfering indexes ...' GO CREATE INDEX con_ref1 ON conspects5(server,db) WITH FILLFACTOR=100 CREATE INDEX con_ref2 ON conspects5(server,db,tbl) WITH FILLFACTOR=100 GO CREATE INDEX qqqq ON view_item4(id,tbl) WITH FILLFACTOR=100 GO CREATE INDEX repfk ON object(report_id) WITH FILLFACTOR=100 GO CREATE INDEX ref1 ON param(report_id) WITH FILLFACTOR=100 GO CREATE INDEX ref1 ON graph_pos(report_id,graph_id) WITH FILLFACTOR=100 CREATE INDEX ref2 ON graph_pos(ord) WITH FILLFACTOR=100 GO CREATE INDEX attr_ref ON graph_attribute(colid) WITH FILLFACTOR=100 CREATE INDEX graph_ref ON graph_attribute(graph_id) WITH FILLFACTOR=100 CREATE INDEX report_ref ON graph_attribute(report_id) WITH FILLFACTOR=100 GO CREATE INDEX graph_ref ON graph_color(graph_id) WITH FILLFACTOR=100 CREATE INDEX report_ref ON graph_color(report_id) WITH FILLFACTOR=100 GO CREATE INDEX objfk ON attribute(object_id) WITH FILLFACTOR=100 CREATE INDEX repfk ON attribute(report_id) WITH FILLFACTOR=100 GO CREATE INDEX ref1 ON ptree(db,parent) WITH FILLFACTOR=100 CREATE INDEX ref2 ON ptree(db,child,ch_type) WITH FILLFACTOR=100 GO CREATE INDEX ref1 ON report_error(report_id) WITH FILLFACTOR=100 GO CREATE INDEX not_ref1 ON notes5(db) WITH FILLFACTOR=100 CREATE INDEX not_ref2 ON notes5(db,tbl) WITH FILLFACTOR=100 CREATE INDEX not_ref3 ON notes5(db,tbl,usr) WITH FILLFACTOR=100 GO CREATE INDEX rel4ind ON rel5(server,db) WITH FILLFACTOR=100 GO CREATE UNIQUE INDEX qq ON rel_view5(id) WITH FILLFACTOR=100 CREATE INDEX ref1 ON rel_view5(server,db) WITH FILLFACTOR=100 GO CREATE INDEX ref1 ON md_def5(server,db) WITH FILLFACTOR=100 CREATE INDEX ref2 ON md_def5(b_history) WITH FILLFACTOR=100 GO CREATE INDEX ref1 ON md_history5(server,db,tbl,colid,feature_ord) WITH FILLFACTOR=100 CREATE INDEX ref2 ON md_history5(d_change) WITH FILLFACTOR=100 GO CREATE INDEX ref1 ON md_data5(server,db) WITH FILLFACTOR=100 CREATE INDEX ref2 ON md_data5(server,db,tbl) WITH FILLFACTOR=100 GO CREATE INDEX ref1 ON tabexpand5(server,db) WITH FILLFACTOR=100 CREATE INDEX ref2 ON tabexpand5(server,usr,db) WITH FILLFACTOR=100 GO CREATE INDEX keysaddind1 ON keysadd5(server) WITH FILLFACTOR=100 CREATE INDEX keysaddind2 ON keysadd5(db,id,depid,key1) WITH FILLFACTOR=100 CREATE INDEX keysaddind3 ON keysadd5(server,db,id,depid,key1,key2,key3,key4,key5,key6,key7,key8) WITH FILLFACTOR=100 GO PRINT 'Transfering triggers ...' GO PRINT 'Trans. options_UITrig' GO CREATE TRIGGER options_UITrig ON options FOR UPDATE, INSERT AS UPDATE options SET last_update=HOST_NAME() FROM options, inserted WHERE inserted.opt_name=options.opt_name GO PRINT 'Trans. graph_attribute_ITrig' GO CREATE TRIGGER graph_attribute_ITrig ON graph_attribute FOR INSERT AS DECLARE @rc int SELECT @rc=@@rowcount IF @rc!=(SELECT DISTINCT COUNT(*) FROM graph r, inserted i WHERE i.report_id=r.report_id AND i.graph_id=r.graph_id) BEGIN ROLLBACK TRANSACTION RAISERROR 44447 'Vlo?enie do tabu3ky ''graph_attribute'' poru?uje RI s ''graph'' ' RETURN END GO PRINT 'Trans. graph_attribute_UTrig' GO CREATE TRIGGER graph_attribute_UTrig ON graph_attribute FOR UPDATE AS DECLARE @rc int SELECT @rc=@@rowcount IF UPDATE(report_id) OR UPDATE(graph_id) IF @rc!=(SELECT DISTINCT COUNT(*) FROM graph r, inserted i WHERE i.report_id=r.report_id AND i.graph_id=r.graph_id) BEGIN ROLLBACK TRANSACTION RAISERROR 44446 'Zmeny v detskej tabu3ke ''graph_attribute'' poru?uj· RI s ''graph'' ' RETURN END GO PRINT 'Trans. graph_color_ITrig' GO CREATE TRIGGER graph_color_ITrig ON graph_color FOR INSERT AS DECLARE @rc int SELECT @rc=@@rowcount IF @rc!=(SELECT DISTINCT COUNT(*) FROM graph r, inserted i WHERE i.report_id=r.report_id AND i.graph_id=r.graph_id) BEGIN ROLLBACK TRANSACTION RAISERROR 44447 'Vlo?enie do tabu3ky ''graph_color'' poru?uje RI s ''graph'' ' RETURN END GO PRINT 'Trans. graph_color_UTrig' GO CREATE TRIGGER graph_color_UTrig ON graph_color FOR UPDATE AS DECLARE @rc int SELECT @rc=@@rowcount IF UPDATE(report_id) OR UPDATE(graph_id) IF @rc!=(SELECT DISTINCT COUNT(*) FROM graph r, inserted i WHERE i.report_id=r.report_id AND i.graph_id=r.graph_id) BEGIN ROLLBACK TRANSACTION RAISERROR 44446 'Zmeny v detskej tabu3ke ''graph_color'' poru?uj· RI s ''graph'' ' RETURN END GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='workdb')>0 DROP VIEW dbo.workdb GO PRINT 'Trans. workdb' GO create view workdb as select name, sourcedb, status from workdb4 GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='rel4')>0 DROP VIEW dbo.rel4 GO PRINT 'Trans. rel4' GO CREATE VIEW rel4 AS SELECT db, tbl, vx, vy, cx, cy, flags FROM rel5 WHERE server=(SELECT srvname FROM master..sysservers WHERE srvid=0) GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='rel')>0 DROP VIEW dbo.rel GO PRINT 'Trans. rel' GO create view rel as select db, tbl, vx, vy, cx, cy from rel4 GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='keysadd4')>0 DROP VIEW dbo.keysadd4 GO PRINT 'Trans. keysadd4' GO CREATE VIEW keysadd4 AS SELECT db, id, depid, flags, str, key1, key2, key3, key4, key5, key6, key7, key8, key9, key10, key11, key12, key13, key14, key15, key16 FROM keysadd5 WHERE server=(SELECT srvname FROM master..sysservers WHERE srvid=0) GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='keysadd')>0 DROP VIEW dbo.keysadd GO PRINT 'Trans. keysadd' GO create view keysadd as select db, id, depid, flags, str from keysadd4 GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='view_item')>0 DROP VIEW dbo.view_item GO PRINT 'Trans. view_item' GO create view view_item as select id, tbl, vx, vy, cx, cy, flags from view_item4 GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='patriklog4')>0 DROP VIEW dbo.patriklog4 GO PRINT 'Trans. patriklog4' GO CREATE VIEW patriklog4 AS SELECT db, tbl, flags FROM patriklog5 WHERE server=(SELECT srvname FROM master..sysservers WHERE srvid=0) GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='patriklog')>0 DROP VIEW dbo.patriklog GO PRINT 'Trans. patriklog' GO create view patriklog as select db, tbl from patriklog4 GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='conspects')>0 DROP VIEW dbo.conspects GO PRINT 'Trans. conspects' GO CREATE VIEW conspects AS SELECT db, tbl, colid, comment FROM conspects5 WHERE server=(SELECT srvname FROM master..sysservers WHERE srvid=0) GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='md_data')>0 DROP VIEW dbo.md_data GO PRINT 'Trans. md_data' GO CREATE VIEW md_data AS SELECT db, tbl, colid, data FROM md_data5 WHERE server=(SELECT srvname FROM master..sysservers WHERE srvid=0) GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='md_def')>0 DROP VIEW dbo.md_def GO PRINT 'Trans. md_def' GO CREATE VIEW md_def AS SELECT db, feature, width, ord, b_history FROM md_def5 WHERE server=(SELECT srvname FROM master..sysservers WHERE srvid=0) GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='md_history')>0 DROP VIEW dbo.md_history GO PRINT 'Trans. md_history' GO CREATE VIEW md_history AS SELECT db, tbl, colid, feature_ord, d_change, data, usr FROM md_history5 WHERE server=(SELECT srvname FROM master..sysservers WHERE srvid=0) GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='notes')>0 DROP VIEW dbo.notes GO PRINT 'Trans. notes' GO CREATE VIEW notes AS SELECT db, tbl, whr, usr, comment FROM notes5 WHERE server=(SELECT srvname FROM master..sysservers WHERE srvid=0) GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='rel_view')>0 DROP VIEW dbo.rel_view GO PRINT 'Trans. rel_view' GO CREATE VIEW rel_view AS SELECT id, name, db, usr FROM rel_view5 WHERE server=(SELECT srvname FROM master..sysservers WHERE srvid=0) GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='report')>0 DROP VIEW dbo.report GO PRINT 'Trans. report' GO CREATE VIEW report AS SELECT report_id, db, name, description, flags, sample_lines, rel_flags, rel_x, rel_y, last_changed, s_select, rel_scale, s_where, prolog_procedure, epilog_procedure, lt_locker FROM report5 WHERE server=(SELECT srvname FROM master..sysservers WHERE srvid=0) GO IF (SELECT COUNT(*) FROM sysobjects WHERE name='tabexpand')>0 DROP VIEW dbo.tabexpand GO PRINT 'Trans. tabexpand' GO CREATE VIEW tabexpand AS SELECT usr, db, tbl, op, colid, arg FROM tabexpand5 WHERE server=(SELECT srvname FROM master..sysservers WHERE srvid=0) GO PRINT 'Trans. keys_ITrig' GO CREATE TRIGGER keys_ITrig ON keys FOR INSERT AS DECLARE @rc int SELECT @rc=@@rowcount IF @rc!=(SELECT DISTINCT COUNT(*) FROM object r, inserted i WHERE i.object_id=r.object_id) BEGIN ROLLBACK TRANSACTION RAISERROR 44447 'Vlo?enie do tabu3ky ''keys'' poru?uje RI s ''object'' ' RETURN END GO PRINT 'Trans. keys_UTrig' GO CREATE TRIGGER keys_UTrig ON keys FOR UPDATE AS DECLARE @rc int SELECT @rc=@@rowcount IF UPDATE(object_id) IF @rc!=(SELECT DISTINCT COUNT(*) FROM object r, inserted i WHERE i.object_id=r.object_id) BEGIN ROLLBACK TRANSACTION RAISERROR 44446 'Zmeny v detskej tabu3ke ''keys'' poru?uj· RI s ''object'' ' RETURN END GO PRINT 'Trans. graph_pos_ITrig' GO CREATE TRIGGER graph_pos_ITrig ON graph_pos FOR INSERT AS DECLARE @rc int SELECT @rc=@@rowcount IF @rc!=(SELECT DISTINCT COUNT(*) FROM graph r, inserted i WHERE i.report_id=r.report_id AND i.graph_id=r.graph_id) BEGIN ROLLBACK TRANSACTION RAISERROR 44447 'Vlo?enie do tabu3ky ''graph_pos'' poru?uje RI s ''graph'' ' RETURN END GO PRINT 'Trans. graph_pos_UTrig' GO CREATE TRIGGER graph_pos_UTrig ON graph_pos FOR UPDATE AS DECLARE @rc int SELECT @rc=@@rowcount IF UPDATE(report_id) OR UPDATE(graph_id) IF @rc!=(SELECT DISTINCT COUNT(*) FROM graph r, inserted i WHERE i.report_id=r.report_id AND i.graph_id=r.graph_id) BEGIN ROLLBACK TRANSACTION RAISERROR 44446 'Zmeny v detskej tabu3ke ''graph_pos'' poru?uj· RI s ''graph'' ' RETURN END GO PRINT 'Trans. orderby_ITrig' GO CREATE TRIGGER orderby_ITrig ON orderby FOR INSERT AS DECLARE @rc int SELECT @rc=@@rowcount IF @rc!=(SELECT DISTINCT COUNT(*) FROM report5 r, inserted i WHERE i.report_id=r.report_id) BEGIN ROLLBACK TRANSACTION RAISERROR 44447 'Vlo₧enie do tabu╛ky ''orderby'' poruÜuje RI s ''report5'' ' RETURN END GO PRINT 'Trans. orderby_UTrig' GO CREATE TRIGGER orderby_UTrig ON orderby FOR UPDATE AS DECLARE @rc int SELECT @rc=COUNT(*) FROM inserted IF UPDATE(report_id) IF @rc!=(SELECT DISTINCT COUNT(*) FROM report5 r, inserted i WHERE i.report_id=r.report_id) BEGIN ROLLBACK TRANSACTION RAISERROR 44446 'Zmeny v detskej tabu╛ke ''orderby'' poruÜuj· RI s ''report5'' ' RETURN END GO PRINT 'Trans. graph_DTrig' GO CREATE TRIGGER graph_DTrig ON graph FOR DELETE AS DELETE graph_attribute FROM graph_attribute, deleted WHERE deleted.report_id=graph_attribute.report_id AND deleted.graph_id=graph_attribute.graph_id DELETE graph_color FROM graph_color, deleted WHERE deleted.report_id=graph_color.report_id AND deleted.graph_id=graph_color.graph_id GO PRINT 'Trans. graph_UTrig' GO CREATE TRIGGER graph_UTrig ON graph FOR UPDATE AS DECLARE @rc int SELECT @rc=COUNT(*) FROM inserted IF UPDATE(report_id) OR UPDATE(graph_id) IF @rc<2 UPDATE graph_attribute SET graph_attribute.report_id=inserted.report_id, graph_attribute.graph_id=inserted.graph_id FROM graph_attribute, deleted, inserted WHERE graph_attribute.report_id=deleted.report_id AND graph_attribute.graph_id=deleted.graph_id ELSE BEGIN ROLLBACK TRANSACTION RAISERROR 44440 'Viacriadkovß kaskßdovß zmena v ''graph'' ' RETURN END IF UPDATE(report_id) OR UPDATE(graph_id) IF @rc<2 UPDATE graph_color SET graph_color.report_id=inserted.report_id, graph_color.graph_id=inserted.graph_id FROM graph_color, deleted, inserted WHERE graph_color.report_id=deleted.report_id AND graph_color.graph_id=deleted.graph_id ELSE BEGIN ROLLBACK TRANSACTION RAISERROR 44440 'Viacriadkovß kaskßdovß zmena v ''graph'' ' RETURN END GO PRINT 'Trans. report5_UTrig' GO CREATE TRIGGER report5_UTrig ON report5 FOR UPDATE AS DECLARE @rc int SELECT @rc=COUNT(*) FROM inserted IF UPDATE(report_id) IF @rc<2 UPDATE attribute SET attribute.report_id=inserted.report_id FROM attribute, deleted, inserted WHERE attribute.report_id=deleted.report_id ELSE BEGIN ROLLBACK TRANSACTION RAISERROR 44440 'Viacriadkovß kaskßdovß zmena v ''report5'' ' RETURN END IF UPDATE(report_id) IF @rc<2 UPDATE layout SET layout.report_id=inserted.report_id FROM layout, deleted, inserted WHERE layout.report_id=deleted.report_id ELSE BEGIN ROLLBACK TRANSACTION RAISERROR 44440 'Viacriadkovß kaskßdovß zmena v ''report5'' ' RETURN END IF UPDATE(report_id) IF @rc<2 UPDATE object SET object.report_id=inserted.report_id FROM object, deleted, inserted WHERE object.report_id=deleted.report_id ELSE BEGIN ROLLBACK TRANSACTION RAISERROR 44440 'Viacriadkovß kaskßdovß zmena v ''report5'' ' RETURN END IF UPDATE(report_id) IF @rc<2 UPDATE orderby SET orderby.report_id=inserted.report_id FROM orderby, deleted, inserted WHERE orderby.report_id=deleted.report_id ELSE BEGIN ROLLBACK TRANSACTION RAISERROR 44440 'Viacriadkovß kaskßdovß zmena v ''report5'' ' RETURN END GO PRINT 'Trans. report5_DTrig' GO CREATE TRIGGER report5_DTrig ON report5 FOR DELETE AS DELETE attribute FROM attribute, deleted WHERE deleted.report_id=attribute.report_id DELETE layout FROM layout, deleted WHERE deleted.report_id=layout.report_id DELETE object FROM object, deleted WHERE deleted.report_id=object.report_id DELETE orderby FROM orderby, deleted WHERE deleted.report_id=orderby.report_id GO PRINT 'Trans. object_DTrig' GO CREATE TRIGGER object_DTrig ON object FOR DELETE AS DELETE keys FROM keys, deleted WHERE deleted.object_id=keys.object_id GO PRINT 'Trans. object_ITrig' GO CREATE TRIGGER object_ITrig ON object FOR INSERT AS DECLARE @rc int SELECT @rc=@@rowcount IF @rc!=(SELECT DISTINCT COUNT(*) FROM report5 r, inserted i WHERE i.report_id=r.report_id) BEGIN ROLLBACK TRANSACTION RAISERROR 44447 'Vlo₧enie do tabu╛ky ''object'' poruÜuje RI s ''report5'' ' RETURN END GO PRINT 'Trans. object_UTrig' GO CREATE TRIGGER object_UTrig ON object FOR UPDATE AS DECLARE @rc int SELECT @rc=COUNT(*) FROM inserted IF UPDATE(object_id) IF @rc<2 UPDATE keys SET keys.object_id=inserted.object_id FROM keys, deleted, inserted WHERE keys.object_id=deleted.object_id ELSE BEGIN ROLLBACK TRANSACTION RAISERROR 44440 'Viacriadkovß kaskßdovß zmena v ''object'' ' RETURN END IF UPDATE(report_id) IF @rc!=(SELECT DISTINCT COUNT(*) FROM report5 r, inserted i WHERE i.report_id=r.report_id) BEGIN ROLLBACK TRANSACTION RAISERROR 44446 'Zmeny v detskej tabu╛ke ''object'' poruÜuj· RI s ''report5'' ' RETURN END GO PRINT 'Trans. layout_ITrig' GO CREATE TRIGGER layout_ITrig ON layout FOR INSERT AS DECLARE @rc int SELECT @rc=@@rowcount IF @rc!=(SELECT DISTINCT COUNT(*) FROM report5 r, inserted i WHERE i.report_id=r.report_id) BEGIN ROLLBACK TRANSACTION RAISERROR 44447 'Vlo₧enie do tabu╛ky ''layout'' poruÜuje RI s ''report5'' ' RETURN END GO PRINT 'Trans. layout_UTrig' GO CREATE TRIGGER layout_UTrig ON layout FOR UPDATE AS DECLARE @rc int SELECT @rc=COUNT(*) FROM inserted IF UPDATE(report_id) IF @rc!=(SELECT DISTINCT COUNT(*) FROM report5 r, inserted i WHERE i.report_id=r.report_id) BEGIN ROLLBACK TRANSACTION RAISERROR 44446 'Zmeny v detskej tabu╛ke ''layout'' poruÜuj· RI s ''report5'' ' RETURN END GO PRINT 'Trans. attribute_ITrig' GO CREATE TRIGGER attribute_ITrig ON attribute FOR INSERT AS DECLARE @rc int SELECT @rc=@@rowcount IF @rc!=(SELECT DISTINCT COUNT(*) FROM report5 r, inserted i WHERE i.report_id=r.report_id) BEGIN ROLLBACK TRANSACTION RAISERROR 44447 'Vlo₧enie do tabu╛ky ''attribute'' poruÜuje RI s ''report5'' ' RETURN END GO PRINT 'Trans. attribute_UTrig' GO CREATE TRIGGER attribute_UTrig ON attribute FOR UPDATE AS DECLARE @rc int SELECT @rc=COUNT(*) FROM inserted IF UPDATE(report_id) IF @rc!=(SELECT DISTINCT COUNT(*) FROM report5 r, inserted i WHERE i.report_id=r.report_id) BEGIN ROLLBACK TRANSACTION RAISERROR 44446 'Zmeny v detskej tabu╛ke ''attribute'' poruÜuj· RI s ''report5'' ' RETURN END GO PRINT 'Transfering keys ...' GO sp_primarykey attribute, report_id, attribute_id DELETE rel WHERE db='patrik' AND tbl='attribute' INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'attribute', 172, 92, 113, 245) DELETE patriklog WHERE db='patrik' AND tbl='attribute' DELETE rel WHERE db='patrik' AND tbl='conspects5' INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'conspects5', 320, 976, 112, 85) DELETE patriklog WHERE db='patrik' AND tbl='conspects5' GO sp_primarykey graph, report_id, graph_id DELETE rel WHERE db='patrik' AND tbl='graph' INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'graph', 724, 32, 132, 629) DELETE patriklog WHERE db='patrik' AND tbl='graph' DELETE rel WHERE db='patrik' AND tbl='graph_attribute' INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'graph_attribute', 1005, 124, 112, 85) DELETE patriklog WHERE db='patrik' AND tbl='graph_attribute' GO sp_primarykey graph_color, report_id, graph_id, ord DELETE rel WHERE db='patrik' AND tbl='graph_color' INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'graph_color', 1001, 17, 112, 85) DELETE patriklog WHERE db='patrik' AND tbl='graph_color' DELETE rel WHERE db='patrik' AND tbl='graph_pos' INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'graph_pos', 1013, 221, 112, 101) DELETE patriklog WHERE db='patrik' AND tbl='graph_pos' GO sp_primarykey keys, object_id, object_depid, key_id DELETE rel WHERE db='patrik' AND tbl='keys' INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'keys', 21, 261, 112, 341) DELETE patriklog WHERE db='patrik' AND tbl='keys' DELETE rel WHERE db='patrik' AND tbl='keysadd5' INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'keysadd5', 405, 641, 112, 357) DELETE patriklog WHERE db='patrik' AND tbl='keysadd5' GO sp_primarykey layout, report_id DELETE rel WHERE db='patrik' AND tbl='layout' INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'layout', 520, 396, 136, 693) DELETE patriklog WHERE db='patrik' AND tbl='layout' DELETE rel WHERE db='patrik' AND tbl='md_data5' INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'md_data5', 1073, 520, 112, 85) DELETE patriklog WHERE db='patrik' AND tbl='md_data5' DELETE rel WHERE db='patrik' AND tbl='md_def5' INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'md_def5', 1069, 408, 112, 101) DELETE patriklog WHERE db='patrik' AND tbl='md_def5' DELETE rel WHERE db='patrik' AND tbl='md_history5' INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'md_history5', 968, 472, 112, 133) DELETE patriklog WHERE db='patrik' AND tbl='md_history5' DELETE rel WHERE db='patrik' AND tbl='notes5' INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'notes5', 320, 641, 112, 101) DELETE patriklog WHERE db='patrik' AND tbl='notes5' GO sp_primarykey object, object_id DELETE rel WHERE db='patrik' AND tbl='object' INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'object', 25, 25, 112, 213) DELETE patriklog WHERE db='patrik' AND tbl='object' DELETE rel WHERE db='patrik' AND tbl='options' INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'options', 960, 752, 112, 85) DELETE patriklog WHERE db='patrik' AND tbl='options' GO sp_primarykey orderby, report_id, orderby_id DELETE rel WHERE db='patrik' AND tbl='orderby' INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'orderby', 353, 121, 112, 85) DELETE patriklog WHERE db='patrik' AND tbl='orderby' GO sp_primarykey param, report_id, set_name DELETE rel WHERE db='patrik' AND tbl='param' INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'param', 344, 420, 112, 85) DELETE patriklog WHERE db='patrik' AND tbl='param' DELETE rel WHERE db='patrik' AND tbl='patriklog5' INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'patriklog5', 321, 893, 112, 69) DELETE patriklog WHERE db='patrik' AND tbl='patriklog5' DELETE rel WHERE db='patrik' AND tbl='ptree' INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'ptree', 212, 896, 112, 85) DELETE patriklog WHERE db='patrik' AND tbl='ptree' GO sp_primarykey rel_view5, id DELETE rel WHERE db='patrik' AND tbl='rel_view5' INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'rel_view5', 756, 909, 112, 85) DELETE patriklog WHERE db='patrik' AND tbl='rel_view5' DELETE rel WHERE db='patrik' AND tbl='rel5' INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'rel5', 337, 753, 112, 133) DELETE patriklog WHERE db='patrik' AND tbl='rel5' DELETE rel WHERE db='patrik' AND tbl='report_error' INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'report_error', 329, 284, 112, 85) DELETE patriklog WHERE db='patrik' AND tbl='report_error' GO sp_primarykey report5, report_id DELETE rel WHERE db='patrik' AND tbl='report5' INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'report5', 521, 32, 134, 277) DELETE patriklog WHERE db='patrik' AND tbl='report5' DELETE rel WHERE db='patrik' AND tbl='tabexpand5' INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'tabexpand5', 210, 764, 112, 117) DELETE patriklog WHERE db='patrik' AND tbl='tabexpand5' DELETE rel WHERE db='patrik' AND tbl='version' INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'version', 1068, 756, 112, 53) DELETE patriklog WHERE db='patrik' AND tbl='version' GO sp_primarykey view_item4, id, tbl DELETE rel WHERE db='patrik' AND tbl='view_item4' INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'view_item4', 896, 916, 112, 165) DELETE patriklog WHERE db='patrik' AND tbl='view_item4' DELETE rel WHERE db='patrik' AND tbl='workdb4' INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'workdb4', 196, 640, 112, 101) DELETE patriklog WHERE db='patrik' AND tbl='workdb4' GO sp_foreignkey attribute, object, object_id DELETE keysadd4 WHERE db='patrik' AND id='attribute' AND depid='object' AND isnull(key1, 0)=3 INSERT keysadd4 SELECT 'patrik', 'attribute', 'object', 0, '#', 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 GO sp_foreignkey attribute, report5, report_id DELETE keysadd4 WHERE db='patrik' AND id='attribute' AND depid='report5' AND isnull(key1, 0)=1 INSERT keysadd4 SELECT 'patrik', 'attribute', 'report5', 30, '#', 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 GO sp_foreignkey graph, report5, report_id DELETE keysadd4 WHERE db='patrik' AND id='graph' AND depid='report5' AND isnull(key1, 0)=1 INSERT keysadd4 SELECT 'patrik', 'graph', 'report5', 0, '#', 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 GO sp_foreignkey graph_attribute, graph, report_id, graph_id DELETE keysadd4 WHERE db='patrik' AND id='graph_attribute' AND depid='graph' AND isnull(key1, 0)=1 AND isnull(key2, 0)=2 INSERT keysadd4 SELECT 'patrik', 'graph_attribute', 'graph', 30, 'ffff#rrr', 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 GO sp_foreignkey graph_color, graph, report_id, graph_id DELETE keysadd4 WHERE db='patrik' AND id='graph_color' AND depid='graph' AND isnull(key1, 0)=1 AND isnull(key2, 0)=2 INSERT keysadd4 SELECT 'patrik', 'graph_color', 'graph', 30, '#', 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 GO sp_foreignkey graph_pos, graph, report_id, graph_id DELETE keysadd4 WHERE db='patrik' AND id='graph_pos' AND depid='graph' AND isnull(key1, 0)=1 AND isnull(key2, 0)=2 INSERT keysadd4 SELECT 'patrik', 'graph_pos', 'graph', 0, '', 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 GO sp_foreignkey keys, object, object_id DELETE keysadd4 WHERE db='patrik' AND id='keys' AND depid='object' AND isnull(key1, 0)=1 INSERT keysadd4 SELECT 'patrik', 'keys', 'object', 30, '#', 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 GO sp_foreignkey layout, report5, report_id DELETE keysadd4 WHERE db='patrik' AND id='layout' AND depid='report5' AND isnull(key1, 0)=1 INSERT keysadd4 SELECT 'patrik', 'layout', 'report5', 30, '#', 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 GO sp_foreignkey object, report5, report_id DELETE keysadd4 WHERE db='patrik' AND id='object' AND depid='report5' AND isnull(key1, 0)=2 INSERT keysadd4 SELECT 'patrik', 'object', 'report5', 30, '#', 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 GO sp_foreignkey orderby, attribute, report_id, attribute_id DELETE keysadd4 WHERE db='patrik' AND id='orderby' AND depid='attribute' AND isnull(key1, 0)=1 AND isnull(key2, 0)=3 INSERT keysadd4 SELECT 'patrik', 'orderby', 'attribute', 0, '#', 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 GO sp_foreignkey orderby, report5, report_id DELETE keysadd4 WHERE db='patrik' AND id='orderby' AND depid='report5' AND isnull(key1, 0)=1 INSERT keysadd4 SELECT 'patrik', 'orderby', 'report5', 30, '#', 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 GO sp_foreignkey param, report5, report_id DELETE keysadd4 WHERE db='patrik' AND id='param' AND depid='report5' AND isnull(key1, 0)=1 INSERT keysadd4 SELECT 'patrik', 'param', 'report5', 0, '', 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 GO sp_foreignkey report_error, report5, report_id DELETE keysadd4 WHERE db='patrik' AND id='report_error' AND depid='report5' AND isnull(key1, 0)=1 INSERT keysadd4 SELECT 'patrik', 'report_error', 'report5', 0, '', 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 GO sp_foreignkey view_item4, rel_view5, id DELETE keysadd4 WHERE db='patrik' AND id='view_item4' AND depid='rel_view5' AND isnull(key1, 0)=1 INSERT keysadd4 SELECT 'patrik', 'view_item4', 'rel_view5', 0, '', 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 PRINT 'Transfering procedures & views ...' GO DELETE notes WHERE db='patrik' AND tbl='version' GO DELETE notes WHERE db='patrik' AND tbl='workdb4' GO DELETE notes WHERE db='patrik' AND tbl='view_item4' GO DELETE notes WHERE db='patrik' AND tbl='options' GO DELETE notes WHERE db='patrik' AND tbl='orderby' GO DELETE notes WHERE db='patrik' AND tbl='graph' INSERT notes VALUES('patrik', 'graph', 'psu', '', 'Graph table') GO DELETE notes WHERE db='patrik' AND tbl='keys' GO DELETE notes WHERE db='patrik' AND tbl='object' GO DELETE notes WHERE db='patrik' AND tbl='param' GO DELETE notes WHERE db='patrik' AND tbl='graph_pos' GO DELETE notes WHERE db='patrik' AND tbl='graph_attribute' GO DELETE notes WHERE db='patrik' AND tbl='graph_color' GO DELETE notes WHERE db='patrik' AND tbl='layout' GO DELETE notes WHERE db='patrik' AND tbl='attribute' INSERT notes VALUES('patrik', 'attribute', '', 'psu', 'adfjk skjdflskjf sfdd sdfs ') GO DELETE notes WHERE db='patrik' AND tbl='ptree' GO DELETE notes WHERE db='patrik' AND tbl='report_error' GO DELETE notes WHERE db='patrik' AND tbl='workdb' GO DELETE notes WHERE db='patrik' AND tbl='rel' GO DELETE notes WHERE db='patrik' AND tbl='keysadd' GO DELETE notes WHERE db='patrik' AND tbl='view_item' GO DELETE notes WHERE db='patrik' AND tbl='patriklog' GO DELETE notes WHERE db='patrik' AND tbl='conspects5' INSERT notes VALUES('patrik', 'conspects5', '', '', 'Table containts descriptions of columns of tables.') GO DELETE notes WHERE db='patrik' AND tbl='notes5' INSERT notes VALUES('patrik', 'notes5', '', '', 'Table containts notes to tables on server(s).') GO DELETE notes WHERE db='patrik' AND tbl='rel5' INSERT notes VALUES('patrik', 'rel5', '', '', 'Table with positions of tables in relational models.') GO DELETE notes WHERE db='patrik' AND tbl='keysadd5' INSERT notes VALUES('patrik', 'keysadd5', '', '', 'Table Containts informations about relations.') GO DELETE notes WHERE db='patrik' AND tbl='patriklog5' INSERT notes VALUES('patrik', 'patriklog5', '', '', 'tracks info of tables having history kept') GO DELETE notes WHERE db='patrik' AND tbl='rel_view5' INSERT notes VALUES('patrik', 'rel_view5', '', '', 'Directory with relational views.') GO DELETE notes WHERE db='patrik' AND tbl='report5' INSERT notes VALUES('patrik', 'report5', '', '', 'Table containts directory of reports for server(s).') GO DELETE notes WHERE db='patrik' AND tbl='md_def5' INSERT notes VALUES('patrik', 'md_def5', '', '', 'Definition of metadata for databases.') GO DELETE notes WHERE db='patrik' AND tbl='md_data5' INSERT notes VALUES('patrik', 'md_data5', '', '', 'Table containts metadata for tables.') GO DELETE notes WHERE db='patrik' AND tbl='md_history5' INSERT notes VALUES('patrik', 'md_history5', '', '', 'History of changes in table md_data.') GO DELETE notes WHERE db='patrik' AND tbl='tabexpand5' INSERT notes VALUES('patrik', 'tabexpand5', '', '', 'Table contains definitions of data of tables to be open. here is predefined default sort, autofilters, expands etc.') GO DELETE notes WHERE db='patrik' AND tbl='conspects' GO DELETE notes WHERE db='patrik' AND tbl='keysadd4' GO DELETE notes WHERE db='patrik' AND tbl='md_data' GO DELETE notes WHERE db='patrik' AND tbl='syssegments' GO DELETE notes WHERE db='patrik' AND tbl='md_def' GO DELETE notes WHERE db='patrik' AND tbl='sysconstraints' GO DELETE notes WHERE db='patrik' AND tbl='md_history' GO DELETE notes WHERE db='patrik' AND tbl='sysalternates' GO DELETE notes WHERE db='patrik' AND tbl='notes' GO DELETE notes WHERE db='patrik' AND tbl='patriklog4' GO DELETE notes WHERE db='patrik' AND tbl='rel_view' GO DELETE notes WHERE db='patrik' AND tbl='rel4' GO DELETE notes WHERE db='patrik' AND tbl='report' GO DELETE notes WHERE db='patrik' AND tbl='tabexpand' GO DELETE conspects WHERE db='patrik' AND tbl='attribute' INSERT conspects VALUES('patrik', 'attribute', 1, 'FK report') INSERT conspects VALUES('patrik', 'attribute', 2, 'PK') INSERT conspects VALUES('patrik', 'attribute', 3, 'parent object, may be NULL') INSERT conspects VALUES('patrik', 'attribute', 4, 'FK name of object''s attribute, if object_id is null then custom field') INSERT conspects VALUES('patrik', 'attribute', 5, 'PK name of atribute') INSERT conspects VALUES('patrik', 'attribute', 7, 'agregate function used') INSERT conspects VALUES('patrik', 'attribute', 10, 'top exception') INSERT conspects VALUES('patrik', 'attribute', 11, 'top exception value') INSERT conspects VALUES('patrik', 'attribute', 12, 'bottom exception') INSERT conspects VALUES('patrik', 'attribute', 13, 'bottom exception value') INSERT conspects VALUES('patrik', 'attribute', 14, 'col->id; join to graph_attribute') DELETE conspects WHERE db='patrik' AND tbl='conspects5' INSERT conspects VALUES('patrik', 'conspects5', 1, 'server name') INSERT conspects VALUES('patrik', 'conspects5', 2, 'database') INSERT conspects VALUES('patrik', 'conspects5', 3, 'table') INSERT conspects VALUES('patrik', 'conspects5', 4, 'column id') INSERT conspects VALUES('patrik', 'conspects5', 5, 'text of comment') DELETE conspects WHERE db='patrik' AND tbl='graph' INSERT conspects VALUES('patrik', 'graph', 3, 'graph name') INSERT conspects VALUES('patrik', 'graph', 4, 'type of graph') INSERT conspects VALUES('patrik', 'graph', 5, 'surxcolor') INSERT conspects VALUES('patrik', 'graph', 6, 'surycolor') GO INSERT conspects VALUES('patrik', 'graph', 7, 'surzcolor') INSERT conspects VALUES('patrik', 'graph', 8, 'bk_color') INSERT conspects VALUES('patrik', 'graph', 9, 'graphcolor') INSERT conspects VALUES('patrik', 'graph', 10, 'palettestart') INSERT conspects VALUES('patrik', 'graph', 11, 'paletteend') INSERT conspects VALUES('patrik', 'graph', 12, 'textcolor') INSERT conspects VALUES('patrik', 'graph', 13, 'podlozkacolor') INSERT conspects VALUES('patrik', 'graph', 14, 'lwidth') INSERT conspects VALUES('patrik', 'graph', 21, 'rot.a') INSERT conspects VALUES('patrik', 'graph', 22, 'rot.b') INSERT conspects VALUES('patrik', 'graph', 23, 'rot.c') INSERT conspects VALUES('patrik', 'graph', 24, 'number of string graph attributes') INSERT conspects VALUES('patrik', 'graph', 25, 'stena1') INSERT conspects VALUES('patrik', 'graph', 26, 'stena2') INSERT conspects VALUES('patrik', 'graph', 27, 'stena3') INSERT conspects VALUES('patrik', 'graph', 29, 'stlpec') INSERT conspects VALUES('patrik', 'graph', 31, 'und, ital, bold, strikeout') DELETE conspects WHERE db='patrik' AND tbl='graph_color' INSERT conspects VALUES('patrik', 'graph_color', 1, 'fk') INSERT conspects VALUES('patrik', 'graph_color', 2, 'fk') INSERT conspects VALUES('patrik', 'graph_color', 3, 'order of color') GO INSERT conspects VALUES('patrik', 'graph_color', 4, 'color value (RGB)') DELETE conspects WHERE db='patrik' AND tbl='keys' INSERT conspects VALUES('patrik', 'keys', 1, 'FK Object') INSERT conspects VALUES('patrik', 'keys', 2, 'FK Object') INSERT conspects VALUES('patrik', 'keys', 3, 'contraint id') INSERT conspects VALUES('patrik', 'keys', 4, 'join type, virtual relation') INSERT conspects VALUES('patrik', 'keys', 5, 'one based indexes to object columns') DELETE conspects WHERE db='patrik' AND tbl='keysadd5' INSERT conspects VALUES('patrik', 'keysadd5', 1, 'server') INSERT conspects VALUES('patrik', 'keysadd5', 2, 'database') INSERT conspects VALUES('patrik', 'keysadd5', 3, 'foreign table name') INSERT conspects VALUES('patrik', 'keysadd5', 4, 'primary table name') INSERT conspects VALUES('patrik', 'keysadd5', 5, 'relation type') INSERT conspects VALUES('patrik', 'keysadd5', 6, 'relation comment') INSERT conspects VALUES('patrik', 'keysadd5', 7, 'foreign columns...') DELETE conspects WHERE db='patrik' AND tbl='layout' INSERT conspects VALUES('patrik', 'layout', 1, 'parent report') INSERT conspects VALUES('patrik', 'layout', 2, 'preview flags') INSERT conspects VALUES('patrik', 'layout', 3, 'margins') INSERT conspects VALUES('patrik', 'layout', 9, 'header text') DELETE conspects WHERE db='patrik' AND tbl='md_data5' INSERT conspects VALUES('patrik', 'md_data5', 4, 'table column order') INSERT conspects VALUES('patrik', 'md_data5', 5, '0x01 delimited metadata for column') DELETE conspects WHERE db='patrik' AND tbl='md_def5' INSERT conspects VALUES('patrik', 'md_def5', 1, 'server name') GO INSERT conspects VALUES('patrik', 'md_def5', 2, 'database, which tables has described particular features') INSERT conspects VALUES('patrik', 'md_def5', 3, 'Metadata - documented feature') INSERT conspects VALUES('patrik', 'md_def5', 4, 'width of column (NULL = the widest value width)') INSERT conspects VALUES('patrik', 'md_def5', 5, 'order of feature between others') INSERT conspects VALUES('patrik', 'md_def5', 6, 'log historyu of changes in md_history?') DELETE conspects WHERE db='patrik' AND tbl='md_history5' INSERT conspects VALUES('patrik', 'md_history5', 1, 'server name') INSERT conspects VALUES('patrik', 'md_history5', 4, 'column id (order number)') INSERT conspects VALUES('patrik', 'md_history5', 5, 'feature ordinal number') INSERT conspects VALUES('patrik', 'md_history5', 6, 'time of change') INSERT conspects VALUES('patrik', 'md_history5', 7, 'new value') INSERT conspects VALUES('patrik', 'md_history5', 8, 'NT Domain\User which made the change.') DELETE conspects WHERE db='patrik' AND tbl='notes5' INSERT conspects VALUES('patrik', 'notes5', 1, 'server name') INSERT conspects VALUES('patrik', 'notes5', 4, 'where condition for notes to non table objects') INSERT conspects VALUES('patrik', 'notes5', 5, 'user, made the note') INSERT conspects VALUES('patrik', 'notes5', 6, 'text of note') DELETE conspects WHERE db='patrik' AND tbl='object' INSERT conspects VALUES('patrik', 'object', 3, '1=TABLE, 2=VIEW, 3=REPORT') INSERT conspects VALUES('patrik', 'object', 4, 'name of table, view or report') INSERT conspects VALUES('patrik', 'object', 11, 'optimizer hint index') DELETE conspects WHERE db='patrik' AND tbl='orderby' INSERT conspects VALUES('patrik', 'orderby', 1, 'FK report') INSERT conspects VALUES('patrik', 'orderby', 2, 'order') GO INSERT conspects VALUES('patrik', 'orderby', 3, 'FK') INSERT conspects VALUES('patrik', 'orderby', 4, 'descent?') DELETE conspects WHERE db='patrik' AND tbl='patriklog5' INSERT conspects VALUES('patrik', 'patriklog5', 1, 'server name') INSERT conspects VALUES('patrik', 'patriklog5', 4, 'unused') DELETE conspects WHERE db='patrik' AND tbl='rel_view5' INSERT conspects VALUES('patrik', 'rel_view5', 1, 'server name') INSERT conspects VALUES('patrik', 'rel_view5', 5, 'owner') DELETE conspects WHERE db='patrik' AND tbl='rel5' INSERT conspects VALUES('patrik', 'rel5', 1, 'server name') INSERT conspects VALUES('patrik', 'rel5', 8, 'unused') DELETE conspects WHERE db='patrik' AND tbl='report5' INSERT conspects VALUES('patrik', 'report5', 2, 'server name') INSERT conspects VALUES('patrik', 'report5', 7, 'number of lines in report sample data') INSERT conspects VALUES('patrik', 'report5', 8, 'relational model flags') INSERT conspects VALUES('patrik', 'report5', 9, 'position of view viewed in RM') INSERT conspects VALUES('patrik', 'report5', 11, 'NT username who have last changed report') INSERT conspects VALUES('patrik', 'report5', 12, 'column name free select') INSERT conspects VALUES('patrik', 'report5', 13, 'scale of relational model in designer') INSERT conspects VALUES('patrik', 'report5', 14, 'where condition for report') INSERT conspects VALUES('patrik', 'report5', 15, 'executes before report is read') INSERT conspects VALUES('patrik', 'report5', 16, 'executes after report is read') INSERT conspects VALUES('patrik', 'report5', 17, 'login time of locker''s process') DELETE conspects WHERE db='patrik' AND tbl='tabexpand5' INSERT conspects VALUES('patrik', 'tabexpand5', 1, 'server name') GO INSERT conspects VALUES('patrik', 'tabexpand5', 5, 'internal') INSERT conspects VALUES('patrik', 'tabexpand5', 7, 'argument for option') GO update rel set db=db_name() where db='patrik' update patriklog set db=db_name() where db='patrik' update keysadd set db=db_name() where db='patrik' update notes set db=db_name() where db='patrik' update conspects set db=db_name() where db='patrik' GO GRANT SELECT ON attribute TO public GRANT SELECT ON conspects TO public GRANT SELECT ON conspects5 TO public GRANT SELECT ON graph TO public GRANT SELECT ON graph_attribute TO public GRANT SELECT ON graph_color TO public GRANT SELECT ON graph_pos TO public GRANT SELECT ON keys TO public GRANT SELECT ON keysadd TO public GRANT SELECT ON keysadd4 TO public GRANT SELECT ON keysadd5 TO public GRANT SELECT ON layout TO public GRANT SELECT ON md_data TO public GRANT SELECT ON md_data5 TO public GRANT SELECT ON md_def TO public GRANT SELECT ON md_def5 TO public GRANT SELECT ON md_history TO public GRANT SELECT ON md_history5 TO public GRANT SELECT ON notes TO public GRANT SELECT ON notes5 TO public GRANT SELECT ON object TO public GRANT SELECT ON options TO public GRANT SELECT ON orderby TO public GRANT SELECT ON param TO public GRANT SELECT ON patriklog TO public GRANT SELECT ON patriklog4 TO public GRANT SELECT ON patriklog5 TO public GRANT SELECT ON ptree TO public GRANT SELECT ON rel TO public GRANT SELECT ON rel_view TO public GRANT SELECT ON rel_view5 TO public GRANT SELECT ON rel4 TO public GRANT SELECT ON rel5 TO public GRANT SELECT ON report TO public GRANT SELECT ON report_error TO public GRANT SELECT ON report5 TO public GRANT SELECT ON tabexpand TO public GRANT SELECT ON tabexpand5 TO public GRANT SELECT ON version TO public GRANT SELECT ON view_item TO public GRANT SELECT ON view_item4 TO public GRANT SELECT ON workdb TO public GRANT SELECT ON workdb4 TO public GO create table licence(szOrg varchar(255), nConnect int, bNumber varbinary(255)) GO GRANT SELECT ON licence TO public GO exec sp_adduser 'guest' GO declare @s varchar(255) select @s='Program Database '''+db_name()+''' installed successfully.' PRINT '' PRINT @s PRINT 'Now You May Start To Use Program.'