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