home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 27 / IOPROG_27.ISO / SOFT / SQLING.EXE / Disk1 / data1.cab / Program_Executable_Files / report_d5.sql < prev    next >
Encoding:
Text File  |  1999-05-24  |  56.1 KB  |  1,766 lines

  1. GO
  2. IF (SELECT COUNT(*) FROM sysobjects WHERE name='this_server')>0 DROP DEFAULT dbo.this_server
  3. GO
  4. CREATE DEFAULT this_server AS @@servername
  5. GO
  6. IF (SELECT COUNT(*) FROM sysobjects WHERE name='_version')>0
  7.    DROP TABLE _version
  8. GO
  9. CREATE TABLE version
  10. (
  11.    version int NULL,
  12.    revision int NULL
  13. )
  14. PRINT 'Creating table workdb4'
  15. GO
  16. IF (SELECT COUNT(*) FROM sysobjects WHERE name='_workdb4')>0
  17.    DROP TABLE _workdb4
  18. GO
  19. CREATE TABLE workdb4
  20. (
  21.    name sysname NOT NULL,
  22.    sourcedb sysname NOT NULL,
  23.    status int NULL,
  24.    dt_downsize datetime NULL,
  25.    s_who varchar(255) NULL,
  26.  CONSTRAINT PK__workdb4__0EA330E9 PRIMARY KEY CLUSTERED (name)
  27. )
  28. PRINT 'Creating table view_item4'
  29. GO
  30. IF (SELECT COUNT(*) FROM sysobjects WHERE name='_view_item4')>0
  31.    DROP TABLE _view_item4
  32. GO
  33. CREATE TABLE view_item4
  34. (
  35.    id int NULL,
  36.    tbl sysname NULL,
  37.    vx int NULL,
  38.    vy int NULL,
  39.    cx int NULL,
  40.    cy int NULL,
  41.    flags int NULL,
  42.    cmt_usr sysname NULL,
  43.    cmt_txt text NULL
  44. )
  45. PRINT 'Creating table options'
  46. GO
  47. IF (SELECT COUNT(*) FROM sysobjects WHERE name='_options')>0
  48.    DROP TABLE _options
  49. GO
  50. CREATE TABLE options
  51. (
  52.    opt_name varchar(255) NOT NULL,
  53.    opt_text varchar(255) NULL,
  54.    opt_int int NULL,
  55.    last_update varchar(30) NULL,
  56.  CONSTRAINT PK__options__1B0907CE PRIMARY KEY CLUSTERED (opt_name)
  57. )
  58. GO
  59. GRANT SELECT ON options TO public
  60. GO
  61. PRINT 'Creating table orderby'
  62. GO
  63. IF (SELECT COUNT(*) FROM sysobjects WHERE name='_orderby')>0
  64.    DROP TABLE _orderby
  65. GO
  66. CREATE TABLE orderby
  67. (
  68.    report_id int NOT NULL,
  69.    orderby_id int NOT NULL,
  70.    attribute_id int NULL,
  71.    b_desc bit NOT NULL,
  72.  CONSTRAINT PK__orderby__1ED998B2 PRIMARY KEY NONCLUSTERED (report_id, orderby_id)
  73. )
  74. GO
  75. GRANT SELECT ON orderby TO public
  76. GO
  77. PRINT 'Creating table graph'
  78. GO
  79. IF (SELECT COUNT(*) FROM sysobjects WHERE name='_graph')>0
  80.    DROP TABLE _graph
  81. GO
  82. CREATE TABLE graph
  83. (
  84.    report_id int NOT NULL,
  85.    graph_id int NOT NULL,
  86.    name varchar(255) NULL,
  87.    graphtype int NULL,
  88.    c_surx int NULL,
  89.    c_sury int NULL,
  90.    c_surz int NULL,
  91.    c_bk int NULL,
  92.    c_graph int NULL,
  93.    c_palettestart int NULL,
  94.    c_paletteend int NULL,
  95.    c_text int NULL,
  96.    c_podlozka int NULL,
  97.    lwidth int NULL,
  98.    bold_r int NULL,
  99.    dec_dig int NULL,
  100.    pier float NULL,
  101.    transparent float NULL,
  102.    light_intensity float NULL,
  103.    flags int NULL,
  104.    rot_a float NULL,
  105.    rot_b float NULL,
  106.    rot_c float NULL,
  107.    nscolid int NULL,
  108.    c_wall1 int NULL,
  109.    c_wall2 int NULL,
  110.    c_wall3 int NULL,
  111.    bar3d_type int NULL,
  112.    col int NULL,
  113.    lfHeight int NULL,
  114.    lfFlags int NULL,
  115.    lfPitchAndFamily tinyint NULL,
  116.    lfFaceName varchar(32) NULL,
  117.    reserved float NULL,
  118.    glHeight int NULL,
  119.    glFlags int NULL,
  120.    glPitchAndFamily int NULL,
  121.    glFaceName varchar(32) NULL,
  122.  CONSTRAINT PK__graph__20C1E124 PRIMARY KEY NONCLUSTERED (report_id, graph_id)
  123. )
  124. GO
  125. --GRANT REFERENCES ON graph TO public
  126. GO
  127. GRANT SELECT ON graph TO public
  128. GO
  129. --GRANT INSERT ON graph TO public
  130. GO
  131. --GRANT DELETE ON graph TO public
  132. GO
  133. --GRANT UPDATE ON graph TO public
  134. PRINT 'Creating table keys'
  135. GO
  136. IF (SELECT COUNT(*) FROM sysobjects WHERE name='_keys')>0
  137.    DROP TABLE _keys
  138. GO
  139. CREATE TABLE keys
  140. (
  141.    object_id int NOT NULL,
  142.    object_depid int NOT NULL,
  143.    key_id int NOT NULL,
  144.    flags int NOT NULL,
  145.    key1 int NULL,
  146.    key2 int NULL,
  147.    key3 int NULL,
  148.    key4 int NULL,
  149.    key5 int NULL,
  150.    key6 int NULL,
  151.    key7 int NULL,
  152.    key8 int NULL,
  153.    depkey1 int NULL,
  154.    depkey2 int NULL,
  155.    depkey3 int NULL,
  156.    depkey4 int NULL,
  157.    depkey5 int NULL,
  158.    depkey6 int NULL,
  159.    depkey7 int NULL,
  160.    depkey8 int NULL,
  161.  CONSTRAINT PK__keys__22AA2996 PRIMARY KEY NONCLUSTERED (object_id, object_depid, key_id)
  162. )
  163. GO
  164. --GRANT REFERENCES ON keys TO public
  165. GO
  166. GRANT SELECT ON keys TO public
  167. GO
  168. --GRANT INSERT ON keys TO public
  169. GO
  170. --GRANT DELETE ON keys TO public
  171. GO
  172. --GRANT UPDATE ON keys TO public
  173. PRINT 'Creating table object'
  174. GO
  175. IF (SELECT COUNT(*) FROM sysobjects WHERE name='_object')>0
  176.    DROP TABLE _object
  177. GO
  178. CREATE TABLE object
  179. (
  180.    object_id int NOT NULL,
  181.    report_id int NOT NULL,
  182.    type int NOT NULL,
  183.    table_name varchar(255) NOT NULL,
  184.    alias_name sysname NULL,
  185.    flags int NOT NULL,
  186.    vx int NOT NULL,
  187.    vy int NOT NULL,
  188.    cx int NOT NULL,
  189.    cy int NOT NULL,
  190.    index_used varchar(32) NULL,
  191.    set_name sysname NULL,
  192.  CONSTRAINT PK__object__29572725 PRIMARY KEY NONCLUSTERED (object_id)
  193. )
  194. GO
  195. --GRANT REFERENCES ON object TO public
  196. GO
  197. GRANT SELECT ON object TO public
  198. GO
  199. --GRANT INSERT ON object TO public
  200. GO
  201. --GRANT DELETE ON object TO public
  202. GO
  203. --GRANT UPDATE ON object TO public
  204. PRINT 'Creating table param'
  205. GO
  206. IF (SELECT COUNT(*) FROM sysobjects WHERE name='_param')>0
  207.    DROP TABLE _param
  208. GO
  209. CREATE TABLE param
  210. (
  211.    report_id int NOT NULL,
  212.    set_name sysname NOT NULL,
  213.    name sysname NOT NULL,
  214.    value varchar(255) NOT NULL
  215. )
  216. GO
  217. --GRANT REFERENCES ON param TO public
  218. GO
  219. GRANT SELECT ON param TO public
  220. GO
  221. --GRANT INSERT ON param TO public
  222. GO
  223. --GRANT DELETE ON param TO public
  224. GO
  225. --GRANT UPDATE ON param TO public
  226. PRINT 'Creating table graph_pos'
  227. GO
  228. IF (SELECT COUNT(*) FROM sysobjects WHERE name='_graph_pos')>0
  229.    DROP TABLE _graph_pos
  230. GO
  231. CREATE TABLE graph_pos
  232. (
  233.    report_id int NULL,
  234.    graph_id int NULL,
  235.    ord int NULL,
  236.    x int NULL,
  237.    y int NULL
  238. )
  239. GO
  240. --GRANT REFERENCES ON graph_pos TO public
  241. GO
  242. GRANT SELECT ON graph_pos TO public
  243. GO
  244. --GRANT INSERT ON graph_pos TO public
  245. GO
  246. --GRANT DELETE ON graph_pos TO public
  247. GO
  248. --GRANT UPDATE ON graph_pos TO public
  249. PRINT 'Creating table graph_attribute'
  250. GO
  251. IF (SELECT COUNT(*) FROM sysobjects WHERE name='_graph_attribute')>0
  252.    DROP TABLE _graph_attribute
  253. GO
  254. CREATE TABLE graph_attribute
  255. (
  256.    report_id int NOT NULL,
  257.    graph_id int NOT NULL,
  258.    colid int NOT NULL,
  259.    ord int NOT NULL
  260. )
  261. GO
  262. --GRANT REFERENCES ON graph_attribute TO public
  263. GO
  264. GRANT SELECT ON graph_attribute TO public
  265. GO
  266. --GRANT INSERT ON graph_attribute TO public
  267. GO
  268. --GRANT DELETE ON graph_attribute TO public
  269. GO
  270. --GRANT UPDATE ON graph_attribute TO public
  271. PRINT 'Creating table graph_color'
  272. GO
  273. IF (SELECT COUNT(*) FROM sysobjects WHERE name='_graph_color')>0
  274.    DROP TABLE _graph_color
  275. GO
  276. CREATE TABLE graph_color
  277. (
  278.    report_id int NOT NULL,
  279.    graph_id int NOT NULL,
  280.    ord int NOT NULL,
  281.    color int NOT NULL,
  282.  CONSTRAINT PK__graph_color__2E1BDC42 PRIMARY KEY NONCLUSTERED (report_id, graph_id, ord)
  283. )
  284. GO
  285. --GRANT REFERENCES ON graph_color TO public
  286. GO
  287. GRANT SELECT ON graph_color TO public
  288. GO
  289. --GRANT INSERT ON graph_color TO public
  290. GO
  291. --GRANT DELETE ON graph_color TO public
  292. GO
  293. --GRANT UPDATE ON graph_color TO public
  294. PRINT 'Creating table layout'
  295. GO
  296. IF (SELECT COUNT(*) FROM sysobjects WHERE name='_layout')>0
  297.    DROP TABLE _layout
  298. GO
  299. CREATE TABLE layout
  300. (
  301.    report_id int NOT NULL,
  302.    flags int NULL,
  303.    m_head int NULL,
  304.    m_top int NULL,
  305.    m_bottom int NULL,
  306.    m_foot int NULL,
  307.    m_left int NULL,
  308.    m_right int NULL,
  309.    t_head text NULL,
  310.    t_foot text NULL,
  311.    hHeight int NULL,
  312.    hFlags int NULL,
  313.    hPitchAndFamily tinyint NULL,
  314.    hFaceName varchar(32) NULL,
  315.    rHeight int NULL,
  316.    rFlags int NULL,
  317.    rPitchAndFamily tinyint NULL,
  318.    rFaceName varchar(32) NULL,
  319.    h0Height int NULL,
  320.    h0Flags int NULL,
  321.    h0PitchAndFamily tinyint NULL,
  322.    h0FaceName varchar(32) NULL,
  323.    h1Height int NULL,
  324.    h1Flags int NULL,
  325.    h1PitchAndFamily tinyint NULL,
  326.    h1FaceName varchar(32) NULL,
  327.    h2Height int NULL,
  328.    h2Flags int NULL,
  329.    h2PitchAndFamily tinyint NULL,
  330.    h2FaceName varchar(32) NULL,
  331.    f0Height int NULL,
  332.    f0Flags int NULL,
  333.    f0PitchAndFamily tinyint NULL,
  334.    f0FaceName varchar(32) NULL,
  335.    f1Height int NULL,
  336.    f1Flags int NULL,
  337.    f1PitchAndFamily tinyint NULL,
  338.    f1FaceName varchar(32) NULL,
  339.    f2Height int NULL,
  340.    f2Flags int NULL,
  341.    f2PitchAndFamily tinyint NULL,
  342.    f2FaceName varchar(32) NULL,
  343.  CONSTRAINT PK__layout__300424B4 PRIMARY KEY NONCLUSTERED (report_id)
  344. )
  345. GO
  346. --GRANT REFERENCES ON layout TO public
  347. GO
  348. GRANT SELECT ON layout TO public
  349. GO
  350. --GRANT INSERT ON layout TO public
  351. GO
  352. --GRANT DELETE ON layout TO public
  353. GO
  354. --GRANT UPDATE ON layout TO public
  355. PRINT 'Creating table attribute'
  356. GO
  357. IF (SELECT COUNT(*) FROM sysobjects WHERE name='_attribute')>0
  358.    DROP TABLE _attribute
  359. GO
  360. CREATE TABLE attribute
  361. (
  362.    report_id int NOT NULL,
  363.    attribute_id int NOT NULL,
  364.    object_id int NULL,
  365.    obj_attr_name varchar(255) NOT NULL,
  366.    name varchar(255) NULL,
  367.    is_null varchar(255) NULL,
  368.    agregate int NOT NULL,
  369.    align int NOT NULL,
  370.    flags int NOT NULL,
  371.    texcp int NOT NULL,
  372.    texcp_val int NULL,
  373.    bexcp int NOT NULL,
  374.    bexcp_val int NULL,
  375.    colid int NULL,
  376.  CONSTRAINT PK__attribute__31EC6D26 PRIMARY KEY NONCLUSTERED (report_id, attribute_id)
  377. )
  378. GO
  379. --GRANT REFERENCES ON attribute TO public
  380. GO
  381. GRANT SELECT ON attribute TO public
  382. GO
  383. --GRANT INSERT ON attribute TO public
  384. GO
  385. --GRANT DELETE ON attribute TO public
  386. GO
  387. --GRANT UPDATE ON attribute TO public
  388. PRINT 'Creating table ptree'
  389. GO
  390. IF (SELECT COUNT(*) FROM sysobjects WHERE name='_ptree')>0
  391.    DROP TABLE _ptree
  392. GO
  393. CREATE TABLE ptree
  394. (
  395.    db sysname NOT NULL,
  396.    parent sysname NOT NULL,
  397.    child sysname NULL,
  398.    ch_type int NOT NULL
  399. )
  400. GO
  401. --GRANT REFERENCES ON ptree TO public
  402. GO
  403. GRANT SELECT ON ptree TO public
  404. GO
  405. --GRANT INSERT ON ptree TO public
  406. GO
  407. --GRANT DELETE ON ptree TO public
  408. GO
  409. --GRANT UPDATE ON ptree TO public
  410. PRINT 'Creating table report_error'
  411. GO
  412. IF (SELECT COUNT(*) FROM sysobjects WHERE name='_report_error')>0
  413.    DROP TABLE _report_error
  414. GO
  415. CREATE TABLE report_error
  416. (
  417.    report_id int NULL,
  418.    d_time datetime NULL,
  419.    usr varchar(30) NULL,
  420.    s_message text NULL
  421. )
  422. GO
  423. --GRANT REFERENCES ON report_error TO public
  424. GO
  425. GRANT SELECT ON report_error TO public
  426. GO
  427. --GRANT INSERT ON report_error TO public
  428. GO
  429. --GRANT DELETE ON report_error TO public
  430. GO
  431. --GRANT UPDATE ON report_error TO public
  432. PRINT 'Creating table conspects5'
  433. GO
  434. IF (SELECT COUNT(*) FROM sysobjects WHERE name='_conspects5')>0
  435.    DROP TABLE _conspects5
  436. GO
  437. CREATE TABLE conspects5
  438. (
  439.    server sysname NOT NULL,
  440.    db sysname NOT NULL,
  441.    tbl sysname NOT NULL,
  442.    colid int NOT NULL,
  443.    comment varchar(255) NULL,
  444.  CONSTRAINT PK__conspects5__52593CB8 PRIMARY KEY CLUSTERED (server, db, tbl, colid)
  445. )
  446. GO
  447. sp_bindefault this_server, 'conspects5.server'
  448. GO
  449. --GRANT REFERENCES ON conspects5 TO public
  450. GO
  451. GRANT SELECT ON conspects5 TO public
  452. GO
  453. --GRANT INSERT ON conspects5 TO public
  454. GO
  455. --GRANT DELETE ON conspects5 TO public
  456. GO
  457. --GRANT UPDATE ON conspects5 TO public
  458. PRINT 'Creating table notes5'
  459. GO
  460. IF (SELECT COUNT(*) FROM sysobjects WHERE name='_notes5')>0
  461.    DROP TABLE _notes5
  462. GO
  463. CREATE TABLE notes5
  464. (
  465.    server sysname NOT NULL,
  466.    db sysname NOT NULL,
  467.    tbl sysname NOT NULL,
  468.    whr varchar(255) NULL,
  469.    usr sysname NOT NULL,
  470.    comment text NULL
  471. )
  472. GO
  473. sp_bindefault this_server, 'notes5.server'
  474. GO
  475. --GRANT REFERENCES ON notes5 TO public
  476. GO
  477. GRANT SELECT ON notes5 TO public
  478. GO
  479. --GRANT INSERT ON notes5 TO public
  480. GO
  481. --GRANT DELETE ON notes5 TO public
  482. GO
  483. --GRANT UPDATE ON notes5 TO public
  484. PRINT 'Creating table rel5'
  485. GO
  486. IF (SELECT COUNT(*) FROM sysobjects WHERE name='_rel5')>0
  487.    DROP TABLE _rel5
  488. GO
  489. CREATE TABLE rel5
  490. (
  491.    server sysname NOT NULL,
  492.    db sysname NOT NULL,
  493.    tbl sysname NOT NULL,
  494.    vx int NULL,
  495.    vy int NULL,
  496.    cx int NULL,
  497.    cy int NULL,
  498.    flags int NULL,
  499.  CONSTRAINT PK__rel5__5535A963 PRIMARY KEY CLUSTERED (server, db, tbl)
  500. )
  501. GO
  502. sp_bindefault this_server, 'rel5.server'
  503. GO
  504. --GRANT REFERENCES ON rel5 TO public
  505. GO
  506. GRANT SELECT ON rel5 TO public
  507. GO
  508. --GRANT INSERT ON rel5 TO public
  509. GO
  510. --GRANT DELETE ON rel5 TO public
  511. GO
  512. --GRANT UPDATE ON rel5 TO public
  513. PRINT 'Creating table keysadd5'
  514. GO
  515. IF (SELECT COUNT(*) FROM sysobjects WHERE name='_keysadd5')>0
  516.    DROP TABLE _keysadd5
  517. GO
  518. CREATE TABLE keysadd5
  519. (
  520.    server sysname NOT NULL,
  521.    db sysname NULL,
  522.    id sysname NULL,
  523.    depid sysname NULL,
  524.    flags int NULL,
  525.    str varchar(255) NULL,
  526.    key1 int NULL,
  527.    key2 int NULL,
  528.    key3 int NULL,
  529.    key4 int NULL,
  530.    key5 int NULL,
  531.    key6 int NULL,
  532.    key7 int NULL,
  533.    key8 int NULL,
  534.    key9 int NULL,
  535.    key10 int NULL,
  536.    key11 int NULL,
  537.    key12 int NULL,
  538.    key13 int NULL,
  539.    key14 int NULL,
  540.    key15 int NULL,
  541.    key16 int NULL
  542. )
  543. GO
  544. sp_bindefault this_server, 'keysadd5.server'
  545. GO
  546. --GRANT REFERENCES ON keysadd5 TO public
  547. GO
  548. GRANT SELECT ON keysadd5 TO public
  549. GO
  550. --GRANT INSERT ON keysadd5 TO public
  551. GO
  552. --GRANT DELETE ON keysadd5 TO public
  553. GO
  554. --GRANT UPDATE ON keysadd5 TO public
  555. PRINT 'Creating table patriklog5'
  556. GO
  557. IF (SELECT COUNT(*) FROM sysobjects WHERE name='_patriklog5')>0
  558.    DROP TABLE _patriklog5
  559. GO
  560. CREATE TABLE patriklog5
  561. (
  562.    server sysname NOT NULL,
  563.    db sysname NOT NULL,
  564.    tbl sysname NOT NULL,
  565.    flags int NULL,
  566.  CONSTRAINT PK__patriklog5__5812160E PRIMARY KEY CLUSTERED (server, db, tbl)
  567. )
  568. GO
  569. sp_bindefault this_server, 'patriklog5.server'
  570. GO
  571. --GRANT REFERENCES ON patriklog5 TO public
  572. GO
  573. GRANT SELECT ON patriklog5 TO public
  574. GO
  575. --GRANT INSERT ON patriklog5 TO public
  576. GO
  577. --GRANT DELETE ON patriklog5 TO public
  578. GO
  579. --GRANT UPDATE ON patriklog5 TO public
  580. PRINT 'Creating table rel_view5'
  581. GO
  582. IF (SELECT COUNT(*) FROM sysobjects WHERE name='_rel_view5')>0
  583.    DROP TABLE _rel_view5
  584. GO
  585. CREATE TABLE rel_view5
  586. (
  587.    server sysname NOT NULL,
  588.    id int NULL,
  589.    name sysname NULL,
  590.    db sysname NULL,
  591.    usr sysname NULL
  592. )
  593. GO
  594. sp_bindefault this_server, 'rel_view5.server'
  595. GO
  596. --GRANT REFERENCES ON rel_view5 TO public
  597. GO
  598. GRANT SELECT ON rel_view5 TO public
  599. GO
  600. --GRANT INSERT ON rel_view5 TO public
  601. GO
  602. --GRANT DELETE ON rel_view5 TO public
  603. GO
  604. --GRANT UPDATE ON rel_view5 TO public
  605. PRINT 'Creating table report5'
  606. GO
  607. IF (SELECT COUNT(*) FROM sysobjects WHERE name='_report5')>0
  608.    DROP TABLE _report5
  609. GO
  610. CREATE TABLE report5
  611. (
  612.    report_id int NOT NULL,
  613.    server sysname NOT NULL,
  614.    db sysname NOT NULL,
  615.    name sysname NULL,
  616.    description varchar(255) NULL,
  617.    flags int NOT NULL DEFAULT (0),
  618.    sample_lines int NOT NULL DEFAULT (10),
  619.    rel_flags int NOT NULL,
  620.    rel_x int NOT NULL,
  621.    rel_y int NOT NULL,
  622.    last_changed varchar(32) NULL,
  623.    s_select text NULL,
  624.    rel_scale int NULL,
  625.    s_where text NULL,
  626.    prolog_procedure varchar(255) NULL,
  627.    epilog_procedure varchar(255) NULL,
  628.    lt_locker datetime NULL,
  629.  CONSTRAINT PK__report5__5AEE82B9 PRIMARY KEY CLUSTERED (report_id),
  630.  CONSTRAINT UQ__report5__5BE2A6F2 UNIQUE NONCLUSTERED (server, db)
  631. )
  632. GO
  633. sp_bindefault this_server, 'report5.server'
  634. GO
  635. --GRANT REFERENCES ON report5 TO public
  636. GO
  637. GRANT SELECT ON report5 TO public
  638. GO
  639. --GRANT INSERT ON report5 TO public
  640. GO
  641. --GRANT DELETE ON report5 TO public
  642. GO
  643. --GRANT UPDATE ON report5 TO public
  644. PRINT 'Creating table md_def5'
  645. GO
  646. IF (SELECT COUNT(*) FROM sysobjects WHERE name='_md_def5')>0
  647.    DROP TABLE _md_def5
  648. GO
  649. CREATE TABLE md_def5
  650. (
  651.    server sysname NOT NULL,
  652.    db sysname NOT NULL,
  653.    feature varchar(255) NOT NULL,
  654.    width int NULL,
  655.    ord int NOT NULL,
  656.    b_history tinyint NULL,
  657.  CONSTRAINT PK__md_def5__5FB337D6 PRIMARY KEY CLUSTERED (server, db, ord)
  658. )
  659. GO
  660. sp_bindefault this_server, 'md_def5.server'
  661. GO
  662. --GRANT REFERENCES ON md_def5 TO public
  663. GO
  664. GRANT SELECT ON md_def5 TO public
  665. GO
  666. --GRANT INSERT ON md_def5 TO public
  667. GO
  668. --GRANT DELETE ON md_def5 TO public
  669. GO
  670. --GRANT UPDATE ON md_def5 TO public
  671. PRINT 'Creating table md_data5'
  672. GO
  673. IF (SELECT COUNT(*) FROM sysobjects WHERE name='_md_data5')>0
  674.    DROP TABLE _md_data5
  675. GO
  676. CREATE TABLE md_data5
  677. (
  678.    server sysname NOT NULL,
  679.    db sysname NOT NULL,
  680.    tbl sysname NOT NULL,
  681.    colid int NOT NULL,
  682.    data text NOT NULL,
  683.  CONSTRAINT PK__md_data5__619B8048 PRIMARY KEY CLUSTERED (server, db, tbl, colid)
  684. )
  685. GO
  686. sp_bindefault this_server, 'md_data5.server'
  687. GO
  688. --GRANT REFERENCES ON md_data5 TO public
  689. GO
  690. GRANT SELECT ON md_data5 TO public
  691. GO
  692. --GRANT INSERT ON md_data5 TO public
  693. GO
  694. --GRANT DELETE ON md_data5 TO public
  695. GO
  696. --GRANT UPDATE ON md_data5 TO public
  697. PRINT 'Creating table md_history5'
  698. GO
  699. IF (SELECT COUNT(*) FROM sysobjects WHERE name='_md_history5')>0
  700.    DROP TABLE _md_history5
  701. GO
  702. CREATE TABLE md_history5
  703. (
  704.    server sysname NOT NULL,
  705.    db sysname NOT NULL,
  706.    tbl sysname NOT NULL,
  707.    colid int NOT NULL,
  708.    feature_ord int NOT NULL,
  709.    d_change datetime NOT NULL,
  710.    data text NULL,
  711.    usr varchar(65) NOT NULL
  712. )
  713. GO
  714. sp_bindefault this_server, 'md_history5.server'
  715. GO
  716. --GRANT REFERENCES ON md_history5 TO public
  717. GO
  718. GRANT SELECT ON md_history5 TO public
  719. GO
  720. --GRANT INSERT ON md_history5 TO public
  721. GO
  722. --GRANT DELETE ON md_history5 TO public
  723. GO
  724. ----GRANT UPDATE ON md_history5 TO public
  725. PRINT 'Creating table tabexpand5'
  726. GO
  727. IF (SELECT COUNT(*) FROM sysobjects WHERE name='_tabexpand5')>0
  728.    DROP TABLE _tabexpand5
  729. GO
  730. CREATE TABLE tabexpand5
  731. (
  732.    server sysname NOT NULL,
  733.    usr sysname NOT NULL,
  734.    db sysname NOT NULL,
  735.    tbl sysname NOT NULL,
  736.    op int NOT NULL,
  737.    colid int NULL,
  738.    arg varchar(255) NULL
  739. )
  740. GO
  741. sp_bindefault this_server, 'tabexpand5.server'
  742. GO
  743. PRINT 'Transfering indexes ...'
  744. GO
  745. CREATE INDEX con_ref1 ON conspects5(server,db) WITH FILLFACTOR=100
  746. CREATE INDEX con_ref2 ON conspects5(server,db,tbl) WITH FILLFACTOR=100
  747. GO
  748. CREATE INDEX qqqq ON view_item4(id,tbl) WITH FILLFACTOR=100
  749. GO
  750. CREATE INDEX repfk ON object(report_id) WITH FILLFACTOR=100
  751. GO
  752. CREATE INDEX ref1 ON param(report_id) WITH FILLFACTOR=100
  753. GO
  754. CREATE INDEX ref1 ON graph_pos(report_id,graph_id) WITH FILLFACTOR=100
  755. CREATE INDEX ref2 ON graph_pos(ord) WITH FILLFACTOR=100
  756. GO
  757. CREATE INDEX attr_ref ON graph_attribute(colid) WITH FILLFACTOR=100
  758. CREATE INDEX graph_ref ON graph_attribute(graph_id) WITH FILLFACTOR=100
  759. CREATE INDEX report_ref ON graph_attribute(report_id) WITH FILLFACTOR=100
  760. GO
  761. CREATE INDEX graph_ref ON graph_color(graph_id) WITH FILLFACTOR=100
  762. CREATE INDEX report_ref ON graph_color(report_id) WITH FILLFACTOR=100
  763. GO
  764. CREATE INDEX objfk ON attribute(object_id) WITH FILLFACTOR=100
  765. CREATE INDEX repfk ON attribute(report_id) WITH FILLFACTOR=100
  766. GO
  767. CREATE INDEX ref1 ON ptree(db,parent) WITH FILLFACTOR=100
  768. CREATE INDEX ref2 ON ptree(db,child,ch_type) WITH FILLFACTOR=100
  769. GO
  770. CREATE INDEX ref1 ON report_error(report_id) WITH FILLFACTOR=100
  771. GO
  772. CREATE INDEX not_ref1 ON notes5(db) WITH FILLFACTOR=100
  773. CREATE INDEX not_ref2 ON notes5(db,tbl) WITH FILLFACTOR=100
  774. CREATE INDEX not_ref3 ON notes5(db,tbl,usr) WITH FILLFACTOR=100
  775. GO
  776. CREATE INDEX rel4ind ON rel5(server,db) WITH FILLFACTOR=100
  777. GO
  778. CREATE UNIQUE INDEX qq ON rel_view5(id) WITH FILLFACTOR=100
  779. CREATE INDEX ref1 ON rel_view5(server,db) WITH FILLFACTOR=100
  780. GO
  781. CREATE INDEX ref1 ON md_def5(server,db) WITH FILLFACTOR=100
  782. CREATE INDEX ref2 ON md_def5(b_history) WITH FILLFACTOR=100
  783. GO
  784. CREATE INDEX ref1 ON md_history5(server,db,tbl,colid,feature_ord) WITH FILLFACTOR=100
  785. CREATE INDEX ref2 ON md_history5(d_change) WITH FILLFACTOR=100
  786. GO
  787. CREATE INDEX ref1 ON md_data5(server,db) WITH FILLFACTOR=100
  788. CREATE INDEX ref2 ON md_data5(server,db,tbl) WITH FILLFACTOR=100
  789. GO
  790. CREATE INDEX ref1 ON tabexpand5(server,db) WITH FILLFACTOR=100
  791. CREATE INDEX ref2 ON tabexpand5(server,usr,db) WITH FILLFACTOR=100
  792. GO
  793. CREATE INDEX keysaddind1 ON keysadd5(server) WITH FILLFACTOR=100
  794. CREATE INDEX keysaddind2 ON keysadd5(db,id,depid,key1) WITH FILLFACTOR=100
  795. CREATE INDEX keysaddind3 ON keysadd5(server,db,id,depid,key1,key2,key3,key4,key5,key6,key7,key8) WITH FILLFACTOR=100
  796. GO
  797. PRINT 'Transfering triggers ...'
  798. GO
  799. PRINT 'Trans. options_UITrig'
  800. GO
  801. CREATE TRIGGER options_UITrig ON options FOR UPDATE, INSERT
  802. AS
  803. UPDATE options SET last_update=HOST_NAME() FROM options, inserted WHERE inserted.opt_name=options.opt_name
  804. GO
  805. PRINT 'Trans. graph_attribute_ITrig'
  806. GO
  807. CREATE TRIGGER graph_attribute_ITrig ON graph_attribute FOR INSERT
  808. AS
  809.  
  810. DECLARE @rc int
  811. SELECT @rc=@@rowcount
  812. IF @rc!=(SELECT DISTINCT COUNT(*) FROM graph r, inserted i WHERE i.report_id=r.report_id AND i.graph_id=r.graph_id)
  813. BEGIN
  814.   ROLLBACK TRANSACTION
  815.   RAISERROR 44447 'Vlo?enie do tabu3ky ''graph_attribute'' poru?uje RI s ''graph'' '
  816.   RETURN
  817. END
  818.  
  819. GO
  820. PRINT 'Trans. graph_attribute_UTrig'
  821. GO
  822. CREATE TRIGGER graph_attribute_UTrig ON graph_attribute FOR UPDATE
  823. AS
  824.  
  825. DECLARE @rc int
  826. SELECT @rc=@@rowcount
  827. IF UPDATE(report_id) OR UPDATE(graph_id)
  828. IF @rc!=(SELECT DISTINCT COUNT(*) FROM graph r, inserted i WHERE i.report_id=r.report_id AND i.graph_id=r.graph_id)
  829. BEGIN
  830.   ROLLBACK TRANSACTION
  831.   RAISERROR 44446 'Zmeny v detskej tabu3ke ''graph_attribute'' poru?uj· RI s ''graph'' '
  832.   RETURN
  833. END
  834.  
  835. GO
  836. PRINT 'Trans. graph_color_ITrig'
  837. GO
  838. CREATE TRIGGER graph_color_ITrig ON graph_color FOR INSERT
  839. AS
  840.  
  841. DECLARE @rc int
  842. SELECT @rc=@@rowcount
  843. IF @rc!=(SELECT DISTINCT COUNT(*) FROM graph r, inserted i WHERE i.report_id=r.report_id AND i.graph_id=r.graph_id)
  844. BEGIN
  845.   ROLLBACK TRANSACTION
  846.   RAISERROR 44447 'Vlo?enie do tabu3ky ''graph_color'' poru?uje RI s ''graph'' '
  847.   RETURN
  848. END
  849.  
  850. GO
  851. PRINT 'Trans. graph_color_UTrig'
  852. GO
  853. CREATE TRIGGER graph_color_UTrig ON graph_color FOR UPDATE
  854. AS
  855.  
  856. DECLARE @rc int
  857. SELECT @rc=@@rowcount
  858. IF UPDATE(report_id) OR UPDATE(graph_id)
  859. IF @rc!=(SELECT DISTINCT COUNT(*) FROM graph r, inserted i WHERE i.report_id=r.report_id AND i.graph_id=r.graph_id)
  860. BEGIN
  861.   ROLLBACK TRANSACTION
  862.   RAISERROR 44446 'Zmeny v detskej tabu3ke ''graph_color'' poru?uj· RI s ''graph'' '
  863.   RETURN
  864. END
  865.  
  866. GO
  867. IF (SELECT COUNT(*) FROM sysobjects WHERE name='workdb')>0 DROP VIEW dbo.workdb
  868. GO
  869. PRINT 'Trans. workdb'
  870. GO
  871. create view workdb as select name, sourcedb, status from workdb4
  872. GO
  873. IF (SELECT COUNT(*) FROM sysobjects WHERE name='rel4')>0 DROP VIEW dbo.rel4
  874. GO
  875. PRINT 'Trans. rel4'
  876. GO
  877. CREATE VIEW rel4
  878. AS
  879. SELECT db, tbl, vx, vy, cx, cy, flags
  880. FROM rel5
  881. WHERE server=(SELECT srvname FROM master..sysservers WHERE srvid=0)
  882. GO
  883. IF (SELECT COUNT(*) FROM sysobjects WHERE name='rel')>0 DROP VIEW dbo.rel
  884. GO
  885. PRINT 'Trans. rel'
  886. GO
  887. create view rel as select db, tbl, vx, vy, cx, cy from rel4
  888. GO
  889. IF (SELECT COUNT(*) FROM sysobjects WHERE name='keysadd4')>0 DROP VIEW dbo.keysadd4
  890. GO
  891. PRINT 'Trans. keysadd4'
  892. GO
  893. CREATE VIEW keysadd4
  894. AS
  895. SELECT db, id, depid, flags, str, key1, key2, key3, key4, key5, key6, key7, key8, key9, key10, key11, key12, key13, key14, key15, key16
  896. FROM keysadd5
  897. WHERE server=(SELECT srvname FROM master..sysservers WHERE srvid=0)
  898. GO
  899. IF (SELECT COUNT(*) FROM sysobjects WHERE name='keysadd')>0 DROP VIEW dbo.keysadd
  900. GO
  901. PRINT 'Trans. keysadd'
  902. GO
  903. create view keysadd as select db, id, depid, flags, str from keysadd4
  904. GO
  905. IF (SELECT COUNT(*) FROM sysobjects WHERE name='view_item')>0 DROP VIEW dbo.view_item
  906. GO
  907. PRINT 'Trans. view_item'
  908. GO
  909. create view view_item as select id, tbl, vx, vy, cx, cy, flags from view_item4
  910. GO
  911. IF (SELECT COUNT(*) FROM sysobjects WHERE name='patriklog4')>0 DROP VIEW dbo.patriklog4
  912. GO
  913. PRINT 'Trans. patriklog4'
  914. GO
  915. CREATE VIEW patriklog4
  916. AS
  917. SELECT db, tbl, flags
  918. FROM patriklog5
  919. WHERE server=(SELECT srvname FROM master..sysservers WHERE srvid=0)
  920. GO
  921. IF (SELECT COUNT(*) FROM sysobjects WHERE name='patriklog')>0 DROP VIEW dbo.patriklog
  922. GO
  923. PRINT 'Trans. patriklog'
  924. GO
  925. create view patriklog as select db, tbl from patriklog4
  926. GO
  927. IF (SELECT COUNT(*) FROM sysobjects WHERE name='conspects')>0 DROP VIEW dbo.conspects
  928. GO
  929. PRINT 'Trans. conspects'
  930. GO
  931. CREATE VIEW conspects
  932. AS
  933. SELECT db, tbl, colid, comment
  934. FROM conspects5
  935. WHERE server=(SELECT srvname FROM master..sysservers WHERE srvid=0)
  936. GO
  937. IF (SELECT COUNT(*) FROM sysobjects WHERE name='md_data')>0 DROP VIEW dbo.md_data
  938. GO
  939. PRINT 'Trans. md_data'
  940. GO
  941. CREATE VIEW md_data
  942. AS
  943. SELECT db, tbl, colid, data
  944. FROM md_data5
  945. WHERE server=(SELECT srvname FROM master..sysservers WHERE srvid=0)
  946. GO
  947. IF (SELECT COUNT(*) FROM sysobjects WHERE name='md_def')>0 DROP VIEW dbo.md_def
  948. GO
  949. PRINT 'Trans. md_def'
  950. GO
  951. CREATE VIEW md_def
  952. AS
  953. SELECT db, feature, width, ord, b_history
  954. FROM md_def5
  955. WHERE server=(SELECT srvname FROM master..sysservers WHERE srvid=0)
  956. GO
  957. IF (SELECT COUNT(*) FROM sysobjects WHERE name='md_history')>0 DROP VIEW dbo.md_history
  958. GO
  959. PRINT 'Trans. md_history'
  960. GO
  961. CREATE VIEW md_history
  962. AS
  963. SELECT db, tbl, colid, feature_ord, d_change, data, usr
  964. FROM md_history5
  965. WHERE server=(SELECT srvname FROM master..sysservers WHERE srvid=0)
  966. GO
  967. IF (SELECT COUNT(*) FROM sysobjects WHERE name='notes')>0 DROP VIEW dbo.notes
  968. GO
  969. PRINT 'Trans. notes'
  970. GO
  971. CREATE VIEW notes
  972. AS
  973. SELECT db, tbl, whr, usr, comment
  974. FROM notes5
  975. WHERE server=(SELECT srvname FROM master..sysservers WHERE srvid=0)
  976. GO
  977. IF (SELECT COUNT(*) FROM sysobjects WHERE name='rel_view')>0 DROP VIEW dbo.rel_view
  978. GO
  979. PRINT 'Trans. rel_view'
  980. GO
  981. CREATE VIEW rel_view
  982. AS
  983. SELECT id, name, db, usr
  984. FROM rel_view5
  985. WHERE server=(SELECT srvname FROM master..sysservers WHERE srvid=0)
  986. GO
  987. IF (SELECT COUNT(*) FROM sysobjects WHERE name='report')>0 DROP VIEW dbo.report
  988. GO
  989. PRINT 'Trans. report'
  990. GO
  991. CREATE VIEW report
  992. AS
  993. 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
  994. FROM report5
  995. WHERE server=(SELECT srvname FROM master..sysservers WHERE srvid=0)
  996. GO
  997. IF (SELECT COUNT(*) FROM sysobjects WHERE name='tabexpand')>0 DROP VIEW dbo.tabexpand
  998. GO
  999. PRINT 'Trans. tabexpand'
  1000. GO
  1001. CREATE VIEW tabexpand
  1002. AS
  1003. SELECT usr, db, tbl, op, colid, arg
  1004. FROM tabexpand5
  1005. WHERE server=(SELECT srvname FROM master..sysservers WHERE srvid=0)
  1006. GO
  1007. PRINT 'Trans. keys_ITrig'
  1008. GO
  1009. CREATE TRIGGER keys_ITrig ON keys FOR INSERT
  1010. AS
  1011.  
  1012. DECLARE @rc int
  1013. SELECT @rc=@@rowcount
  1014. IF @rc!=(SELECT DISTINCT COUNT(*) FROM object r, inserted i WHERE i.object_id=r.object_id)
  1015. BEGIN
  1016.   ROLLBACK TRANSACTION
  1017.   RAISERROR 44447 'Vlo?enie do tabu3ky ''keys'' poru?uje RI s ''object'' '
  1018.   RETURN
  1019. END
  1020.  
  1021. GO
  1022. PRINT 'Trans. keys_UTrig'
  1023. GO
  1024. CREATE TRIGGER keys_UTrig ON keys FOR UPDATE
  1025. AS
  1026.  
  1027. DECLARE @rc int
  1028. SELECT @rc=@@rowcount
  1029. IF UPDATE(object_id)
  1030. IF @rc!=(SELECT DISTINCT COUNT(*) FROM object r, inserted i WHERE i.object_id=r.object_id)
  1031. BEGIN
  1032.   ROLLBACK TRANSACTION
  1033.   RAISERROR 44446 'Zmeny v detskej tabu3ke ''keys'' poru?uj· RI s ''object'' '
  1034.   RETURN
  1035. END
  1036.  
  1037. GO
  1038. PRINT 'Trans. graph_pos_ITrig'
  1039. GO
  1040. CREATE TRIGGER graph_pos_ITrig ON graph_pos FOR INSERT
  1041. AS
  1042.  
  1043. DECLARE @rc int
  1044. SELECT @rc=@@rowcount
  1045. IF @rc!=(SELECT DISTINCT COUNT(*) FROM graph r, inserted i WHERE i.report_id=r.report_id AND i.graph_id=r.graph_id)
  1046. BEGIN
  1047.   ROLLBACK TRANSACTION
  1048.   RAISERROR 44447 'Vlo?enie do tabu3ky ''graph_pos'' poru?uje RI s ''graph'' '
  1049.   RETURN
  1050. END
  1051.  
  1052. GO
  1053. PRINT 'Trans. graph_pos_UTrig'
  1054. GO
  1055. CREATE TRIGGER graph_pos_UTrig ON graph_pos FOR UPDATE
  1056. AS
  1057.  
  1058. DECLARE @rc int
  1059. SELECT @rc=@@rowcount
  1060. IF UPDATE(report_id) OR UPDATE(graph_id)
  1061. IF @rc!=(SELECT DISTINCT COUNT(*) FROM graph r, inserted i WHERE i.report_id=r.report_id AND i.graph_id=r.graph_id)
  1062. BEGIN
  1063.   ROLLBACK TRANSACTION
  1064.   RAISERROR 44446 'Zmeny v detskej tabu3ke ''graph_pos'' poru?uj· RI s ''graph'' '
  1065.   RETURN
  1066. END
  1067.  
  1068. GO
  1069. PRINT 'Trans. orderby_ITrig'
  1070. GO
  1071. CREATE TRIGGER orderby_ITrig ON orderby FOR INSERT
  1072. AS
  1073.  
  1074. DECLARE @rc int
  1075. SELECT @rc=@@rowcount
  1076. IF @rc!=(SELECT DISTINCT COUNT(*) FROM report5 r, inserted i WHERE i.report_id=r.report_id)
  1077. BEGIN
  1078.   ROLLBACK TRANSACTION
  1079.   RAISERROR 44447 'Vlo₧enie do tabu╛ky ''orderby'' poruÜuje RI s ''report5'' '
  1080.   RETURN
  1081. END
  1082.  
  1083. GO
  1084. PRINT 'Trans. orderby_UTrig'
  1085. GO
  1086. CREATE TRIGGER orderby_UTrig ON orderby FOR UPDATE
  1087. AS
  1088.  
  1089. DECLARE @rc int
  1090. SELECT @rc=COUNT(*) FROM inserted
  1091. IF UPDATE(report_id)
  1092. IF @rc!=(SELECT DISTINCT COUNT(*) FROM report5 r, inserted i WHERE i.report_id=r.report_id)
  1093. BEGIN
  1094.   ROLLBACK TRANSACTION
  1095.   RAISERROR 44446 'Zmeny v detskej tabu╛ke ''orderby'' poruÜuj· RI s ''report5'' '
  1096.   RETURN
  1097. END
  1098.  
  1099. GO
  1100. PRINT 'Trans. graph_DTrig'
  1101. GO
  1102. CREATE TRIGGER graph_DTrig ON graph FOR DELETE
  1103. AS
  1104.  
  1105. DELETE graph_attribute FROM graph_attribute, deleted WHERE deleted.report_id=graph_attribute.report_id AND deleted.graph_id=graph_attribute.graph_id
  1106. DELETE graph_color FROM graph_color, deleted WHERE deleted.report_id=graph_color.report_id AND deleted.graph_id=graph_color.graph_id
  1107.  
  1108. GO
  1109. PRINT 'Trans. graph_UTrig'
  1110. GO
  1111. CREATE TRIGGER graph_UTrig ON graph FOR UPDATE
  1112. AS
  1113.  
  1114. DECLARE @rc int
  1115. SELECT @rc=COUNT(*) FROM inserted
  1116. IF UPDATE(report_id) OR UPDATE(graph_id)
  1117.  IF @rc<2
  1118.   UPDATE graph_attribute SET graph_attribute.report_id=inserted.report_id, graph_attribute.graph_id=inserted.graph_id
  1119.   FROM graph_attribute, deleted, inserted
  1120.   WHERE graph_attribute.report_id=deleted.report_id AND graph_attribute.graph_id=deleted.graph_id
  1121.  ELSE BEGIN
  1122.   ROLLBACK TRANSACTION
  1123.   RAISERROR 44440 'Viacriadkovß kaskßdovß zmena v ''graph'' '
  1124.    RETURN
  1125. END
  1126. IF UPDATE(report_id) OR UPDATE(graph_id)
  1127.  IF @rc<2
  1128.   UPDATE graph_color SET graph_color.report_id=inserted.report_id, graph_color.graph_id=inserted.graph_id
  1129.   FROM graph_color, deleted, inserted
  1130.   WHERE graph_color.report_id=deleted.report_id AND graph_color.graph_id=deleted.graph_id
  1131.  ELSE BEGIN
  1132.   ROLLBACK TRANSACTION
  1133.   RAISERROR 44440 'Viacriadkovß kaskßdovß zmena v ''graph'' '
  1134.    RETURN
  1135. END
  1136.  
  1137. GO
  1138. PRINT 'Trans. report5_UTrig'
  1139. GO
  1140. CREATE TRIGGER report5_UTrig ON report5 FOR UPDATE
  1141. AS
  1142.  
  1143. DECLARE @rc int
  1144. SELECT @rc=COUNT(*) FROM inserted
  1145. IF UPDATE(report_id)
  1146.  IF @rc<2
  1147.   UPDATE attribute SET attribute.report_id=inserted.report_id
  1148.   FROM attribute, deleted, inserted
  1149.   WHERE attribute.report_id=deleted.report_id
  1150.  ELSE BEGIN
  1151.   ROLLBACK TRANSACTION
  1152.   RAISERROR 44440 'Viacriadkovß kaskßdovß zmena v ''report5'' '
  1153.    RETURN
  1154. END
  1155. IF UPDATE(report_id)
  1156.  IF @rc<2
  1157.   UPDATE layout SET layout.report_id=inserted.report_id
  1158.   FROM layout, deleted, inserted
  1159.   WHERE layout.report_id=deleted.report_id
  1160.  ELSE BEGIN
  1161.   ROLLBACK TRANSACTION
  1162.   RAISERROR 44440 'Viacriadkovß kaskßdovß zmena v ''report5'' '
  1163.    RETURN
  1164. END
  1165. IF UPDATE(report_id)
  1166.  IF @rc<2
  1167.   UPDATE object SET object.report_id=inserted.report_id
  1168.   FROM object, deleted, inserted
  1169.   WHERE object.report_id=deleted.report_id
  1170.  ELSE BEGIN
  1171.   ROLLBACK TRANSACTION
  1172.   RAISERROR 44440 'Viacriadkovß kaskßdovß zmena v ''report5'' '
  1173.    RETURN
  1174. END
  1175. IF UPDATE(report_id)
  1176.  IF @rc<2
  1177.   UPDATE orderby SET orderby.report_id=inserted.report_id
  1178.   FROM orderby, deleted, inserted
  1179.   WHERE orderby.report_id=deleted.report_id
  1180.  ELSE BEGIN
  1181.   ROLLBACK TRANSACTION
  1182.   RAISERROR 44440 'Viacriadkovß kaskßdovß zmena v ''report5'' '
  1183.    RETURN
  1184. END
  1185.  
  1186. GO
  1187. PRINT 'Trans. report5_DTrig'
  1188. GO
  1189. CREATE TRIGGER report5_DTrig ON report5 FOR DELETE
  1190. AS
  1191.  
  1192. DELETE attribute FROM attribute, deleted WHERE deleted.report_id=attribute.report_id
  1193. DELETE layout FROM layout, deleted WHERE deleted.report_id=layout.report_id
  1194. DELETE object FROM object, deleted WHERE deleted.report_id=object.report_id
  1195. DELETE orderby FROM orderby, deleted WHERE deleted.report_id=orderby.report_id
  1196.  
  1197. GO
  1198. PRINT 'Trans. object_DTrig'
  1199. GO
  1200. CREATE TRIGGER object_DTrig ON object FOR DELETE
  1201. AS
  1202.  
  1203. DELETE keys FROM keys, deleted WHERE deleted.object_id=keys.object_id
  1204.  
  1205. GO
  1206. PRINT 'Trans. object_ITrig'
  1207. GO
  1208. CREATE TRIGGER object_ITrig ON object FOR INSERT
  1209. AS
  1210.  
  1211. DECLARE @rc int
  1212. SELECT @rc=@@rowcount
  1213. IF @rc!=(SELECT DISTINCT COUNT(*) FROM report5 r, inserted i WHERE i.report_id=r.report_id)
  1214. BEGIN
  1215.   ROLLBACK TRANSACTION
  1216.   RAISERROR 44447 'Vlo₧enie do tabu╛ky ''object'' poruÜuje RI s ''report5'' '
  1217.   RETURN
  1218. END
  1219.  
  1220. GO
  1221. PRINT 'Trans. object_UTrig'
  1222. GO
  1223. CREATE TRIGGER object_UTrig ON object FOR UPDATE
  1224. AS
  1225.  
  1226. DECLARE @rc int
  1227. SELECT @rc=COUNT(*) FROM inserted
  1228. IF UPDATE(object_id)
  1229.  IF @rc<2
  1230.   UPDATE keys SET keys.object_id=inserted.object_id
  1231.   FROM keys, deleted, inserted
  1232.   WHERE keys.object_id=deleted.object_id
  1233.  ELSE BEGIN
  1234.   ROLLBACK TRANSACTION
  1235.   RAISERROR 44440 'Viacriadkovß kaskßdovß zmena v ''object'' '
  1236.    RETURN
  1237. END
  1238. IF UPDATE(report_id)
  1239. IF @rc!=(SELECT DISTINCT COUNT(*) FROM report5 r, inserted i WHERE i.report_id=r.report_id)
  1240. BEGIN
  1241.   ROLLBACK TRANSACTION
  1242.   RAISERROR 44446 'Zmeny v detskej tabu╛ke ''object'' poruÜuj· RI s ''report5'' '
  1243.   RETURN
  1244. END
  1245.  
  1246. GO
  1247. PRINT 'Trans. layout_ITrig'
  1248. GO
  1249. CREATE TRIGGER layout_ITrig ON layout FOR INSERT
  1250. AS
  1251.  
  1252. DECLARE @rc int
  1253. SELECT @rc=@@rowcount
  1254. IF @rc!=(SELECT DISTINCT COUNT(*) FROM report5 r, inserted i WHERE i.report_id=r.report_id)
  1255. BEGIN
  1256.   ROLLBACK TRANSACTION
  1257.   RAISERROR 44447 'Vlo₧enie do tabu╛ky ''layout'' poruÜuje RI s ''report5'' '
  1258.   RETURN
  1259. END
  1260.  
  1261. GO
  1262. PRINT 'Trans. layout_UTrig'
  1263. GO
  1264. CREATE TRIGGER layout_UTrig ON layout FOR UPDATE
  1265. AS
  1266.  
  1267. DECLARE @rc int
  1268. SELECT @rc=COUNT(*) FROM inserted
  1269. IF UPDATE(report_id)
  1270. IF @rc!=(SELECT DISTINCT COUNT(*) FROM report5 r, inserted i WHERE i.report_id=r.report_id)
  1271. BEGIN
  1272.   ROLLBACK TRANSACTION
  1273.   RAISERROR 44446 'Zmeny v detskej tabu╛ke ''layout'' poruÜuj· RI s ''report5'' '
  1274.   RETURN
  1275. END
  1276.  
  1277. GO
  1278. PRINT 'Trans. attribute_ITrig'
  1279. GO
  1280. CREATE TRIGGER attribute_ITrig ON attribute FOR INSERT
  1281. AS
  1282.  
  1283. DECLARE @rc int
  1284. SELECT @rc=@@rowcount
  1285. IF @rc!=(SELECT DISTINCT COUNT(*) FROM report5 r, inserted i WHERE i.report_id=r.report_id)
  1286. BEGIN
  1287.   ROLLBACK TRANSACTION
  1288.   RAISERROR 44447 'Vlo₧enie do tabu╛ky ''attribute'' poruÜuje RI s ''report5'' '
  1289.   RETURN
  1290. END
  1291.  
  1292. GO
  1293. PRINT 'Trans. attribute_UTrig'
  1294. GO
  1295. CREATE TRIGGER attribute_UTrig ON attribute FOR UPDATE
  1296. AS
  1297.  
  1298. DECLARE @rc int
  1299. SELECT @rc=COUNT(*) FROM inserted
  1300. IF UPDATE(report_id)
  1301. IF @rc!=(SELECT DISTINCT COUNT(*) FROM report5 r, inserted i WHERE i.report_id=r.report_id)
  1302. BEGIN
  1303.   ROLLBACK TRANSACTION
  1304.   RAISERROR 44446 'Zmeny v detskej tabu╛ke ''attribute'' poruÜuj· RI s ''report5'' '
  1305.   RETURN
  1306. END
  1307.  
  1308. GO
  1309. PRINT 'Transfering keys ...'
  1310.  
  1311. GO
  1312. sp_primarykey attribute, report_id, attribute_id
  1313. DELETE rel WHERE db='patrik' AND tbl='attribute'
  1314. INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'attribute', 172, 92, 113, 245)
  1315. DELETE patriklog WHERE db='patrik' AND tbl='attribute'
  1316. DELETE rel WHERE db='patrik' AND tbl='conspects5'
  1317. INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'conspects5', 320, 976, 112, 85)
  1318. DELETE patriklog WHERE db='patrik' AND tbl='conspects5'
  1319. GO
  1320. sp_primarykey graph, report_id, graph_id
  1321. DELETE rel WHERE db='patrik' AND tbl='graph'
  1322. INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'graph', 724, 32, 132, 629)
  1323. DELETE patriklog WHERE db='patrik' AND tbl='graph'
  1324. DELETE rel WHERE db='patrik' AND tbl='graph_attribute'
  1325. INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'graph_attribute', 1005, 124, 112, 85)
  1326. DELETE patriklog WHERE db='patrik' AND tbl='graph_attribute'
  1327. GO
  1328. sp_primarykey graph_color, report_id, graph_id, ord
  1329. DELETE rel WHERE db='patrik' AND tbl='graph_color'
  1330. INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'graph_color', 1001, 17, 112, 85)
  1331. DELETE patriklog WHERE db='patrik' AND tbl='graph_color'
  1332. DELETE rel WHERE db='patrik' AND tbl='graph_pos'
  1333. INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'graph_pos', 1013, 221, 112, 101)
  1334. DELETE patriklog WHERE db='patrik' AND tbl='graph_pos'
  1335. GO
  1336. sp_primarykey keys, object_id, object_depid, key_id
  1337. DELETE rel WHERE db='patrik' AND tbl='keys'
  1338. INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'keys', 21, 261, 112, 341)
  1339. DELETE patriklog WHERE db='patrik' AND tbl='keys'
  1340. DELETE rel WHERE db='patrik' AND tbl='keysadd5'
  1341. INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'keysadd5', 405, 641, 112, 357)
  1342. DELETE patriklog WHERE db='patrik' AND tbl='keysadd5'
  1343. GO
  1344. sp_primarykey layout, report_id
  1345. DELETE rel WHERE db='patrik' AND tbl='layout'
  1346. INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'layout', 520, 396, 136, 693)
  1347. DELETE patriklog WHERE db='patrik' AND tbl='layout'
  1348. DELETE rel WHERE db='patrik' AND tbl='md_data5'
  1349. INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'md_data5', 1073, 520, 112, 85)
  1350. DELETE patriklog WHERE db='patrik' AND tbl='md_data5'
  1351. DELETE rel WHERE db='patrik' AND tbl='md_def5'
  1352. INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'md_def5', 1069, 408, 112, 101)
  1353. DELETE patriklog WHERE db='patrik' AND tbl='md_def5'
  1354. DELETE rel WHERE db='patrik' AND tbl='md_history5'
  1355. INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'md_history5', 968, 472, 112, 133)
  1356. DELETE patriklog WHERE db='patrik' AND tbl='md_history5'
  1357. DELETE rel WHERE db='patrik' AND tbl='notes5'
  1358. INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'notes5', 320, 641, 112, 101)
  1359. DELETE patriklog WHERE db='patrik' AND tbl='notes5'
  1360. GO
  1361. sp_primarykey object, object_id
  1362. DELETE rel WHERE db='patrik' AND tbl='object'
  1363. INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'object', 25, 25, 112, 213)
  1364. DELETE patriklog WHERE db='patrik' AND tbl='object'
  1365. DELETE rel WHERE db='patrik' AND tbl='options'
  1366. INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'options', 960, 752, 112, 85)
  1367. DELETE patriklog WHERE db='patrik' AND tbl='options'
  1368. GO
  1369. sp_primarykey orderby, report_id, orderby_id
  1370. DELETE rel WHERE db='patrik' AND tbl='orderby'
  1371. INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'orderby', 353, 121, 112, 85)
  1372. DELETE patriklog WHERE db='patrik' AND tbl='orderby'
  1373. GO
  1374. sp_primarykey param, report_id, set_name
  1375. DELETE rel WHERE db='patrik' AND tbl='param'
  1376. INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'param', 344, 420, 112, 85)
  1377. DELETE patriklog WHERE db='patrik' AND tbl='param'
  1378. DELETE rel WHERE db='patrik' AND tbl='patriklog5'
  1379. INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'patriklog5', 321, 893, 112, 69)
  1380. DELETE patriklog WHERE db='patrik' AND tbl='patriklog5'
  1381. DELETE rel WHERE db='patrik' AND tbl='ptree'
  1382. INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'ptree', 212, 896, 112, 85)
  1383. DELETE patriklog WHERE db='patrik' AND tbl='ptree'
  1384. GO
  1385. sp_primarykey rel_view5, id
  1386. DELETE rel WHERE db='patrik' AND tbl='rel_view5'
  1387. INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'rel_view5', 756, 909, 112, 85)
  1388. DELETE patriklog WHERE db='patrik' AND tbl='rel_view5'
  1389. DELETE rel WHERE db='patrik' AND tbl='rel5'
  1390. INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'rel5', 337, 753, 112, 133)
  1391. DELETE patriklog WHERE db='patrik' AND tbl='rel5'
  1392. DELETE rel WHERE db='patrik' AND tbl='report_error'
  1393. INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'report_error', 329, 284, 112, 85)
  1394. DELETE patriklog WHERE db='patrik' AND tbl='report_error'
  1395. GO
  1396. sp_primarykey report5, report_id
  1397. DELETE rel WHERE db='patrik' AND tbl='report5'
  1398. INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'report5', 521, 32, 134, 277)
  1399. DELETE patriklog WHERE db='patrik' AND tbl='report5'
  1400. DELETE rel WHERE db='patrik' AND tbl='tabexpand5'
  1401. INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'tabexpand5', 210, 764, 112, 117)
  1402. DELETE patriklog WHERE db='patrik' AND tbl='tabexpand5'
  1403. DELETE rel WHERE db='patrik' AND tbl='version'
  1404. INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'version', 1068, 756, 112, 53)
  1405. DELETE patriklog WHERE db='patrik' AND tbl='version'
  1406. GO
  1407. sp_primarykey view_item4, id, tbl
  1408. DELETE rel WHERE db='patrik' AND tbl='view_item4'
  1409. INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'view_item4', 896, 916, 112, 165)
  1410. DELETE patriklog WHERE db='patrik' AND tbl='view_item4'
  1411. DELETE rel WHERE db='patrik' AND tbl='workdb4'
  1412. INSERT rel(db, tbl, vx, vy, cx, cy) VALUES('patrik', 'workdb4', 196, 640, 112, 101)
  1413. DELETE patriklog WHERE db='patrik' AND tbl='workdb4'
  1414. GO
  1415. sp_foreignkey attribute, object, object_id
  1416. DELETE keysadd4 WHERE db='patrik' AND id='attribute' AND depid='object' AND isnull(key1, 0)=3
  1417. INSERT keysadd4 SELECT 'patrik', 'attribute', 'object', 0, '#', 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  1418. GO
  1419. sp_foreignkey attribute, report5, report_id
  1420. DELETE keysadd4 WHERE db='patrik' AND id='attribute' AND depid='report5' AND isnull(key1, 0)=1
  1421. INSERT keysadd4 SELECT 'patrik', 'attribute', 'report5', 30, '#', 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  1422. GO
  1423. sp_foreignkey graph, report5, report_id
  1424. DELETE keysadd4 WHERE db='patrik' AND id='graph' AND depid='report5' AND isnull(key1, 0)=1
  1425. INSERT keysadd4 SELECT 'patrik', 'graph', 'report5', 0, '#', 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  1426. GO
  1427. sp_foreignkey graph_attribute, graph, report_id, graph_id
  1428. DELETE keysadd4 WHERE db='patrik' AND id='graph_attribute' AND depid='graph' AND isnull(key1, 0)=1 AND isnull(key2, 0)=2
  1429. 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
  1430. GO
  1431. sp_foreignkey graph_color, graph, report_id, graph_id
  1432. DELETE keysadd4 WHERE db='patrik' AND id='graph_color' AND depid='graph' AND isnull(key1, 0)=1 AND isnull(key2, 0)=2
  1433. INSERT keysadd4 SELECT 'patrik', 'graph_color', 'graph', 30, '#', 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  1434. GO
  1435. sp_foreignkey graph_pos, graph, report_id, graph_id
  1436. DELETE keysadd4 WHERE db='patrik' AND id='graph_pos' AND depid='graph' AND isnull(key1, 0)=1 AND isnull(key2, 0)=2
  1437. INSERT keysadd4 SELECT 'patrik', 'graph_pos', 'graph', 0, '', 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  1438. GO
  1439. sp_foreignkey keys, object, object_id
  1440. DELETE keysadd4 WHERE db='patrik' AND id='keys' AND depid='object' AND isnull(key1, 0)=1
  1441. INSERT keysadd4 SELECT 'patrik', 'keys', 'object', 30, '#', 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  1442. GO
  1443. sp_foreignkey layout, report5, report_id
  1444. DELETE keysadd4 WHERE db='patrik' AND id='layout' AND depid='report5' AND isnull(key1, 0)=1
  1445. INSERT keysadd4 SELECT 'patrik', 'layout', 'report5', 30, '#', 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  1446. GO
  1447. sp_foreignkey object, report5, report_id
  1448. DELETE keysadd4 WHERE db='patrik' AND id='object' AND depid='report5' AND isnull(key1, 0)=2
  1449. INSERT keysadd4 SELECT 'patrik', 'object', 'report5', 30, '#', 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  1450. GO
  1451. sp_foreignkey orderby, attribute, report_id, attribute_id
  1452. DELETE keysadd4 WHERE db='patrik' AND id='orderby' AND depid='attribute' AND isnull(key1, 0)=1 AND isnull(key2, 0)=3
  1453. INSERT keysadd4 SELECT 'patrik', 'orderby', 'attribute', 0, '#', 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  1454. GO
  1455. sp_foreignkey orderby, report5, report_id
  1456. DELETE keysadd4 WHERE db='patrik' AND id='orderby' AND depid='report5' AND isnull(key1, 0)=1
  1457. INSERT keysadd4 SELECT 'patrik', 'orderby', 'report5', 30, '#', 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  1458. GO
  1459. sp_foreignkey param, report5, report_id
  1460. DELETE keysadd4 WHERE db='patrik' AND id='param' AND depid='report5' AND isnull(key1, 0)=1
  1461. INSERT keysadd4 SELECT 'patrik', 'param', 'report5', 0, '', 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  1462. GO
  1463. sp_foreignkey report_error, report5, report_id
  1464. DELETE keysadd4 WHERE db='patrik' AND id='report_error' AND depid='report5' AND isnull(key1, 0)=1
  1465. INSERT keysadd4 SELECT 'patrik', 'report_error', 'report5', 0, '', 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  1466. GO
  1467. sp_foreignkey view_item4, rel_view5, id
  1468. DELETE keysadd4 WHERE db='patrik' AND id='view_item4' AND depid='rel_view5' AND isnull(key1, 0)=1
  1469. 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
  1470. PRINT 'Transfering procedures & views ...'
  1471. GO
  1472. DELETE notes WHERE db='patrik' AND tbl='version'
  1473. GO
  1474. DELETE notes WHERE db='patrik' AND tbl='workdb4'
  1475. GO
  1476. DELETE notes WHERE db='patrik' AND tbl='view_item4'
  1477. GO
  1478. DELETE notes WHERE db='patrik' AND tbl='options'
  1479. GO
  1480. DELETE notes WHERE db='patrik' AND tbl='orderby'
  1481. GO
  1482. DELETE notes WHERE db='patrik' AND tbl='graph'
  1483. INSERT notes VALUES('patrik', 'graph', 'psu', '', 'Graph table')
  1484. GO
  1485. DELETE notes WHERE db='patrik' AND tbl='keys'
  1486. GO
  1487. DELETE notes WHERE db='patrik' AND tbl='object'
  1488. GO
  1489. DELETE notes WHERE db='patrik' AND tbl='param'
  1490. GO
  1491. DELETE notes WHERE db='patrik' AND tbl='graph_pos'
  1492. GO
  1493. DELETE notes WHERE db='patrik' AND tbl='graph_attribute'
  1494. GO
  1495. DELETE notes WHERE db='patrik' AND tbl='graph_color'
  1496. GO
  1497. DELETE notes WHERE db='patrik' AND tbl='layout'
  1498. GO
  1499. DELETE notes WHERE db='patrik' AND tbl='attribute'
  1500. INSERT notes VALUES('patrik', 'attribute', '', 'psu', 'adfjk skjdflskjf
  1501. sfdd sdfs
  1502. ')
  1503. GO
  1504. DELETE notes WHERE db='patrik' AND tbl='ptree'
  1505. GO
  1506. DELETE notes WHERE db='patrik' AND tbl='report_error'
  1507. GO
  1508. DELETE notes WHERE db='patrik' AND tbl='workdb'
  1509. GO
  1510. DELETE notes WHERE db='patrik' AND tbl='rel'
  1511. GO
  1512. DELETE notes WHERE db='patrik' AND tbl='keysadd'
  1513. GO
  1514. DELETE notes WHERE db='patrik' AND tbl='view_item'
  1515. GO
  1516. DELETE notes WHERE db='patrik' AND tbl='patriklog'
  1517. GO
  1518. DELETE notes WHERE db='patrik' AND tbl='conspects5'
  1519. INSERT notes VALUES('patrik', 'conspects5', '', '', 'Table containts descriptions of columns of tables.')
  1520. GO
  1521. DELETE notes WHERE db='patrik' AND tbl='notes5'
  1522. INSERT notes VALUES('patrik', 'notes5', '', '', 'Table containts notes to tables on server(s).')
  1523. GO
  1524. DELETE notes WHERE db='patrik' AND tbl='rel5'
  1525. INSERT notes VALUES('patrik', 'rel5', '', '', 'Table with positions of tables in relational models.')
  1526. GO
  1527. DELETE notes WHERE db='patrik' AND tbl='keysadd5'
  1528. INSERT notes VALUES('patrik', 'keysadd5', '', '', 'Table Containts informations about relations.')
  1529. GO
  1530. DELETE notes WHERE db='patrik' AND tbl='patriklog5'
  1531. INSERT notes VALUES('patrik', 'patriklog5', '', '', 'tracks info of tables having history kept')
  1532. GO
  1533. DELETE notes WHERE db='patrik' AND tbl='rel_view5'
  1534. INSERT notes VALUES('patrik', 'rel_view5', '', '', 'Directory with relational views.')
  1535. GO
  1536. DELETE notes WHERE db='patrik' AND tbl='report5'
  1537. INSERT notes VALUES('patrik', 'report5', '', '', 'Table containts directory of reports for server(s).')
  1538. GO
  1539. DELETE notes WHERE db='patrik' AND tbl='md_def5'
  1540. INSERT notes VALUES('patrik', 'md_def5', '', '', 'Definition of metadata for databases.')
  1541. GO
  1542. DELETE notes WHERE db='patrik' AND tbl='md_data5'
  1543. INSERT notes VALUES('patrik', 'md_data5', '', '', 'Table containts metadata for tables.')
  1544. GO
  1545. DELETE notes WHERE db='patrik' AND tbl='md_history5'
  1546. INSERT notes VALUES('patrik', 'md_history5', '', '', 'History of changes in table md_data.')
  1547. GO
  1548. DELETE notes WHERE db='patrik' AND tbl='tabexpand5'
  1549. INSERT notes VALUES('patrik', 'tabexpand5', '', '', 'Table contains definitions of data of tables to be open. here is predefined default sort, autofilters, expands etc.')
  1550. GO
  1551. DELETE notes WHERE db='patrik' AND tbl='conspects'
  1552. GO
  1553. DELETE notes WHERE db='patrik' AND tbl='keysadd4'
  1554. GO
  1555. DELETE notes WHERE db='patrik' AND tbl='md_data'
  1556. GO
  1557. DELETE notes WHERE db='patrik' AND tbl='syssegments'
  1558. GO
  1559. DELETE notes WHERE db='patrik' AND tbl='md_def'
  1560. GO
  1561. DELETE notes WHERE db='patrik' AND tbl='sysconstraints'
  1562. GO
  1563. DELETE notes WHERE db='patrik' AND tbl='md_history'
  1564. GO
  1565. DELETE notes WHERE db='patrik' AND tbl='sysalternates'
  1566. GO
  1567. DELETE notes WHERE db='patrik' AND tbl='notes'
  1568. GO
  1569. DELETE notes WHERE db='patrik' AND tbl='patriklog4'
  1570. GO
  1571. DELETE notes WHERE db='patrik' AND tbl='rel_view'
  1572. GO
  1573. DELETE notes WHERE db='patrik' AND tbl='rel4'
  1574. GO
  1575. DELETE notes WHERE db='patrik' AND tbl='report'
  1576. GO
  1577. DELETE notes WHERE db='patrik' AND tbl='tabexpand'
  1578. GO
  1579. DELETE conspects WHERE db='patrik' AND tbl='attribute'
  1580. INSERT conspects VALUES('patrik', 'attribute', 1, 'FK report')
  1581. INSERT conspects VALUES('patrik', 'attribute', 2, 'PK')
  1582. INSERT conspects VALUES('patrik', 'attribute', 3, 'parent object, may be NULL')
  1583. INSERT conspects VALUES('patrik', 'attribute', 4, 'FK name of object''s attribute, if object_id is null then custom field')
  1584. INSERT conspects VALUES('patrik', 'attribute', 5, 'PK name of atribute')
  1585. INSERT conspects VALUES('patrik', 'attribute', 7, 'agregate function used')
  1586. INSERT conspects VALUES('patrik', 'attribute', 10, 'top exception')
  1587. INSERT conspects VALUES('patrik', 'attribute', 11, 'top exception value')
  1588. INSERT conspects VALUES('patrik', 'attribute', 12, 'bottom exception')
  1589. INSERT conspects VALUES('patrik', 'attribute', 13, 'bottom exception value')
  1590. INSERT conspects VALUES('patrik', 'attribute', 14, 'col->id; join to graph_attribute')
  1591. DELETE conspects WHERE db='patrik' AND tbl='conspects5'
  1592. INSERT conspects VALUES('patrik', 'conspects5', 1, 'server name')
  1593. INSERT conspects VALUES('patrik', 'conspects5', 2, 'database')
  1594. INSERT conspects VALUES('patrik', 'conspects5', 3, 'table')
  1595. INSERT conspects VALUES('patrik', 'conspects5', 4, 'column id')
  1596. INSERT conspects VALUES('patrik', 'conspects5', 5, 'text of comment')
  1597. DELETE conspects WHERE db='patrik' AND tbl='graph'
  1598. INSERT conspects VALUES('patrik', 'graph', 3, 'graph name')
  1599. INSERT conspects VALUES('patrik', 'graph', 4, 'type of graph')
  1600. INSERT conspects VALUES('patrik', 'graph', 5, 'surxcolor')
  1601. INSERT conspects VALUES('patrik', 'graph', 6, 'surycolor')
  1602. GO
  1603. INSERT conspects VALUES('patrik', 'graph', 7, 'surzcolor')
  1604. INSERT conspects VALUES('patrik', 'graph', 8, 'bk_color')
  1605. INSERT conspects VALUES('patrik', 'graph', 9, 'graphcolor')
  1606. INSERT conspects VALUES('patrik', 'graph', 10, 'palettestart')
  1607. INSERT conspects VALUES('patrik', 'graph', 11, 'paletteend')
  1608. INSERT conspects VALUES('patrik', 'graph', 12, 'textcolor')
  1609. INSERT conspects VALUES('patrik', 'graph', 13, 'podlozkacolor')
  1610. INSERT conspects VALUES('patrik', 'graph', 14, 'lwidth')
  1611. INSERT conspects VALUES('patrik', 'graph', 21, 'rot.a')
  1612. INSERT conspects VALUES('patrik', 'graph', 22, 'rot.b')
  1613. INSERT conspects VALUES('patrik', 'graph', 23, 'rot.c')
  1614. INSERT conspects VALUES('patrik', 'graph', 24, 'number of string graph attributes')
  1615. INSERT conspects VALUES('patrik', 'graph', 25, 'stena1')
  1616. INSERT conspects VALUES('patrik', 'graph', 26, 'stena2')
  1617. INSERT conspects VALUES('patrik', 'graph', 27, 'stena3')
  1618. INSERT conspects VALUES('patrik', 'graph', 29, 'stlpec')
  1619. INSERT conspects VALUES('patrik', 'graph', 31, 'und, ital, bold, strikeout')
  1620. DELETE conspects WHERE db='patrik' AND tbl='graph_color'
  1621. INSERT conspects VALUES('patrik', 'graph_color', 1, 'fk')
  1622. INSERT conspects VALUES('patrik', 'graph_color', 2, 'fk')
  1623. INSERT conspects VALUES('patrik', 'graph_color', 3, 'order of color')
  1624. GO
  1625. INSERT conspects VALUES('patrik', 'graph_color', 4, 'color value (RGB)')
  1626. DELETE conspects WHERE db='patrik' AND tbl='keys'
  1627. INSERT conspects VALUES('patrik', 'keys', 1, 'FK Object')
  1628. INSERT conspects VALUES('patrik', 'keys', 2, 'FK Object')
  1629. INSERT conspects VALUES('patrik', 'keys', 3, 'contraint id')
  1630. INSERT conspects VALUES('patrik', 'keys', 4, 'join type, virtual relation')
  1631. INSERT conspects VALUES('patrik', 'keys', 5, 'one based indexes to object columns')
  1632. DELETE conspects WHERE db='patrik' AND tbl='keysadd5'
  1633. INSERT conspects VALUES('patrik', 'keysadd5', 1, 'server')
  1634. INSERT conspects VALUES('patrik', 'keysadd5', 2, 'database')
  1635. INSERT conspects VALUES('patrik', 'keysadd5', 3, 'foreign table name')
  1636. INSERT conspects VALUES('patrik', 'keysadd5', 4, 'primary table name')
  1637. INSERT conspects VALUES('patrik', 'keysadd5', 5, 'relation type')
  1638. INSERT conspects VALUES('patrik', 'keysadd5', 6, 'relation comment')
  1639. INSERT conspects VALUES('patrik', 'keysadd5', 7, 'foreign columns...')
  1640. DELETE conspects WHERE db='patrik' AND tbl='layout'
  1641. INSERT conspects VALUES('patrik', 'layout', 1, 'parent report')
  1642. INSERT conspects VALUES('patrik', 'layout', 2, 'preview flags')
  1643. INSERT conspects VALUES('patrik', 'layout', 3, 'margins')
  1644. INSERT conspects VALUES('patrik', 'layout', 9, 'header text')
  1645. DELETE conspects WHERE db='patrik' AND tbl='md_data5'
  1646. INSERT conspects VALUES('patrik', 'md_data5', 4, 'table column order')
  1647. INSERT conspects VALUES('patrik', 'md_data5', 5, '0x01 delimited metadata for column')
  1648. DELETE conspects WHERE db='patrik' AND tbl='md_def5'
  1649. INSERT conspects VALUES('patrik', 'md_def5', 1, 'server name')
  1650. GO
  1651. INSERT conspects VALUES('patrik', 'md_def5', 2, 'database, which tables has described particular features')
  1652. INSERT conspects VALUES('patrik', 'md_def5', 3, 'Metadata - documented feature')
  1653. INSERT conspects VALUES('patrik', 'md_def5', 4, 'width of column (NULL = the widest value width)')
  1654. INSERT conspects VALUES('patrik', 'md_def5', 5, 'order of feature between others')
  1655. INSERT conspects VALUES('patrik', 'md_def5', 6, 'log historyu of changes in md_history?')
  1656. DELETE conspects WHERE db='patrik' AND tbl='md_history5'
  1657. INSERT conspects VALUES('patrik', 'md_history5', 1, 'server name')
  1658. INSERT conspects VALUES('patrik', 'md_history5', 4, 'column id (order number)')
  1659. INSERT conspects VALUES('patrik', 'md_history5', 5, 'feature ordinal number')
  1660. INSERT conspects VALUES('patrik', 'md_history5', 6, 'time of change')
  1661. INSERT conspects VALUES('patrik', 'md_history5', 7, 'new value')
  1662. INSERT conspects VALUES('patrik', 'md_history5', 8, 'NT Domain\User which made the change.')
  1663. DELETE conspects WHERE db='patrik' AND tbl='notes5'
  1664. INSERT conspects VALUES('patrik', 'notes5', 1, 'server name')
  1665. INSERT conspects VALUES('patrik', 'notes5', 4, 'where condition for notes to non table objects')
  1666. INSERT conspects VALUES('patrik', 'notes5', 5, 'user, made the note')
  1667. INSERT conspects VALUES('patrik', 'notes5', 6, 'text of note')
  1668. DELETE conspects WHERE db='patrik' AND tbl='object'
  1669. INSERT conspects VALUES('patrik', 'object', 3, '1=TABLE, 2=VIEW, 3=REPORT')
  1670. INSERT conspects VALUES('patrik', 'object', 4, 'name of table, view or report')
  1671. INSERT conspects VALUES('patrik', 'object', 11, 'optimizer hint index')
  1672. DELETE conspects WHERE db='patrik' AND tbl='orderby'
  1673. INSERT conspects VALUES('patrik', 'orderby', 1, 'FK report')
  1674. INSERT conspects VALUES('patrik', 'orderby', 2, 'order')
  1675. GO
  1676. INSERT conspects VALUES('patrik', 'orderby', 3, 'FK')
  1677. INSERT conspects VALUES('patrik', 'orderby', 4, 'descent?')
  1678. DELETE conspects WHERE db='patrik' AND tbl='patriklog5'
  1679. INSERT conspects VALUES('patrik', 'patriklog5', 1, 'server name')
  1680. INSERT conspects VALUES('patrik', 'patriklog5', 4, 'unused')
  1681. DELETE conspects WHERE db='patrik' AND tbl='rel_view5'
  1682. INSERT conspects VALUES('patrik', 'rel_view5', 1, 'server name')
  1683. INSERT conspects VALUES('patrik', 'rel_view5', 5, 'owner')
  1684. DELETE conspects WHERE db='patrik' AND tbl='rel5'
  1685. INSERT conspects VALUES('patrik', 'rel5', 1, 'server name')
  1686. INSERT conspects VALUES('patrik', 'rel5', 8, 'unused')
  1687. DELETE conspects WHERE db='patrik' AND tbl='report5'
  1688. INSERT conspects VALUES('patrik', 'report5', 2, 'server name')
  1689. INSERT conspects VALUES('patrik', 'report5', 7, 'number of lines in report sample data')
  1690. INSERT conspects VALUES('patrik', 'report5', 8, 'relational model flags')
  1691. INSERT conspects VALUES('patrik', 'report5', 9, 'position of view viewed in RM')
  1692. INSERT conspects VALUES('patrik', 'report5', 11, 'NT username who have last changed report')
  1693. INSERT conspects VALUES('patrik', 'report5', 12, 'column name free select')
  1694. INSERT conspects VALUES('patrik', 'report5', 13, 'scale of relational model in designer')
  1695. INSERT conspects VALUES('patrik', 'report5', 14, 'where condition for report')
  1696. INSERT conspects VALUES('patrik', 'report5', 15, 'executes before report is read')
  1697. INSERT conspects VALUES('patrik', 'report5', 16, 'executes after report is read')
  1698. INSERT conspects VALUES('patrik', 'report5', 17, 'login time of locker''s process')
  1699. DELETE conspects WHERE db='patrik' AND tbl='tabexpand5'
  1700. INSERT conspects VALUES('patrik', 'tabexpand5', 1, 'server name')
  1701. GO
  1702. INSERT conspects VALUES('patrik', 'tabexpand5', 5, 'internal')
  1703. INSERT conspects VALUES('patrik', 'tabexpand5', 7, 'argument for option')
  1704. GO
  1705. update rel set db=db_name() where db='patrik'
  1706. update patriklog set db=db_name() where db='patrik'
  1707. update keysadd set db=db_name() where db='patrik'
  1708. update notes set db=db_name() where db='patrik'
  1709. update conspects set db=db_name() where db='patrik'
  1710. GO
  1711. GRANT SELECT ON attribute TO public
  1712. GRANT SELECT ON conspects TO public
  1713. GRANT SELECT ON conspects5 TO public
  1714. GRANT SELECT ON graph TO public
  1715. GRANT SELECT ON graph_attribute TO public
  1716. GRANT SELECT ON graph_color TO public
  1717. GRANT SELECT ON graph_pos TO public
  1718. GRANT SELECT ON keys TO public
  1719. GRANT SELECT ON keysadd TO public
  1720. GRANT SELECT ON keysadd4 TO public
  1721. GRANT SELECT ON keysadd5 TO public
  1722. GRANT SELECT ON layout TO public
  1723. GRANT SELECT ON md_data TO public
  1724. GRANT SELECT ON md_data5 TO public
  1725. GRANT SELECT ON md_def TO public
  1726. GRANT SELECT ON md_def5 TO public
  1727. GRANT SELECT ON md_history TO public
  1728. GRANT SELECT ON md_history5 TO public
  1729. GRANT SELECT ON notes TO public
  1730. GRANT SELECT ON notes5 TO public
  1731. GRANT SELECT ON object TO public
  1732. GRANT SELECT ON options TO public
  1733. GRANT SELECT ON orderby TO public
  1734. GRANT SELECT ON param TO public
  1735. GRANT SELECT ON patriklog TO public
  1736. GRANT SELECT ON patriklog4 TO public
  1737. GRANT SELECT ON patriklog5 TO public
  1738. GRANT SELECT ON ptree TO public
  1739. GRANT SELECT ON rel TO public
  1740. GRANT SELECT ON rel_view TO public
  1741. GRANT SELECT ON rel_view5 TO public
  1742. GRANT SELECT ON rel4 TO public
  1743. GRANT SELECT ON rel5 TO public
  1744. GRANT SELECT ON report TO public
  1745. GRANT SELECT ON report_error TO public
  1746. GRANT SELECT ON report5 TO public
  1747. GRANT SELECT ON tabexpand TO public
  1748. GRANT SELECT ON tabexpand5 TO public
  1749. GRANT SELECT ON version TO public
  1750. GRANT SELECT ON view_item TO public
  1751. GRANT SELECT ON view_item4 TO public
  1752. GRANT SELECT ON workdb TO public
  1753. GRANT SELECT ON workdb4 TO public
  1754. GO
  1755. create table licence(szOrg varchar(255), nConnect int, bNumber varbinary(255))
  1756. GO
  1757. GRANT SELECT ON licence TO public
  1758. GO
  1759. exec sp_adduser 'guest'
  1760. GO
  1761. declare @s varchar(255)
  1762. select @s='Program Database '''+db_name()+''' installed successfully.'
  1763. PRINT ''
  1764. PRINT @s
  1765. PRINT 'Now You May Start To Use Program.'
  1766.