DatabaseProcApplicationCreatedLinks
sybsystemprocssp_addserver  31 Aug 14Defects Dependencies

1     
2     /* Sccsid = "%Z% generic/sproc/src/%M% %I% %G%" */
3     /*	4.8	1.1	06/14/90	sproc/src/addserver */
4     
5     /*
6     ** Messages for "sp_addserver"          17290
7     **
8     ** 17260, "Can't run %1! from within a transaction." 
9     ** 17240, "'" + @lname + "' is not a valid name." 
10    ** 17290, "There is already a server named '%1!', physical name '%2!'."
11    ** 17291, "Usage: sp_addserver servername [, 'local | NULL'] [, physical_name]"
12    ** 17292, "There is already a local server."
13    ** 17293, "Server added."
14    ** 17294, "Changing physical name of server '%1!' from '%2!' to '%3!'"
15    ** 17295, "Adding server '%1!', physical name '%2!'"
16    ** 17296, "Unknown server class '%1!'."
17    ** 17297, "Changing server class of server '%1!' from '%2!' to '%3!'"
18    ** 17869, "Stored procedure %1 failed because %2 failed in database %3."
19    ** 18388, "You must be in the master database in order to run '%1'!."
20    ** 18409, "The built-in function getdbrepstat() failed."
21    ** 18773, "HA_LOG: HA consistency check failure in '%1!' on the companion server '%2!'"
22    ** 18784, "HA warning:Server is currently configured. Any changes to SYB_HACMP or companion server can be serious."
23    ** 18799, "Unable to find a server with name '%1!', id '%2!', and netname '%3!' in sysservers."
24    ** 18800, "A server with name '%1!' and id '%2!' already exists in sysservers."
25    ** 18820, "You cannot change the physical name of server %1! because it is configured as a node of HA cluster."
26    ** 18881, "Unable to generate %1! for HA use. Please Refer to documentation for details."
27    ** 18887, "Cannot have more than one physical or logical server entry for the 
28    ** ASEJB class."
29    ** 19971, "You cannot change the server class of existing server '%1!' from '%2!' to '%3!'."
30    ** 19972, "Local server must use the cluster name as the server name."
31    */
32    
33    /* 
34    ** IMPORTANT: Please read the following instructions before
35    **   making changes to this stored procedure.
36    **
37    **	To make this stored procedure compatible with High Availability (HA),
38    **	changes to certain system tables must be propagated 
39    **	to the companion server under some conditions.
40    **	The tables include (but are not limited to):
41    **		syslogins, sysservers, sysattributes, systimeranges,
42    **		sysresourcelimits, sysalternates, sysdatabases,
43    **		syslanguages, sysremotelogins, sysloginroles,
44    **		sysalternates (master DB only), systypes (master DB only),
45    **		sysusers (master DB only), sysprotects (master DB only)
46    **	please refer to the HA documentation for detail.
47    **
48    **	Here is what you need to do: 
49    **	For each insert/update/delete statement, add three sections to
50    **	-- start HA transaction prior to the statement
51    **	-- add the statement
52    **	-- add HA synchronization code to propagate the change to the companion
53    **
54    **	For example, if you are adding 
55    **		insert master.dbo.syslogins ......
56    **	the code should look like:
57    **	1. Now, the SQL statement:
58    **		insert master.dbo.syslogins ......
59    **	2. Add a HA synchronization section right after the SQL statement:
60    **		
61    **
62    **	You may need to do similar change for each built-in function you
63    **	want to add.
64    */
65    
66    create procedure sp_addserver
67        @lname varchar(255), /* server logical name */
68        @class varchar(15) = "ASEnterprise", /* server class */
69        @pname varchar(255) = NULL /* server physical name */
70    
71    as
72        declare @msg varchar(1024),
73            @netname varchar(255),
74            @dflt_status smallint,
75            @dflt_status2 unsigned int
76    
77        declare @srvclass smallint,
78            @newclass smallint,
79            @srvid smallint,
80            @remotesrvid smallint,
81            @srvcost smallint,
82            @oldclass varchar(255),
83            @dupsrvclass smallint,
84            @outstr varchar(255), /* for SDC dbcc set_scope */
85            @scope varchar(16) /* for SDC dbcc set_scope */
86    
87        declare @maxlen int
88        declare @end_code int
89        declare @HA_CERTIFIED tinyint /* Is the SP HA certified ? */
90        declare @retstat int
91        declare @backupejbflag int
92        declare @isrtds int /* server class is rtds */
93        declare @insysattributes int /* There is row about the changed rtds server in sysattributes */
94        declare @leavertds int /* server class is changed from rtds to non-rtds */
95    
96        declare @bs_name varchar(255) /* BS name to be checked in sysservers table */
97        declare @bs_flag int /* Indicate BS entries in sysservers table */
98        declare @dbname varchar(255) /* for disp dbname in logexec error message */
99        declare @master_is_rep int /* whether master db is replicated */
100   
101       select @HA_CERTIFIED = 0
102       select @backupejbflag = 0
103       select @isrtds = 0
104       select @insysattributes = 0
105       select @leavertds = 0
106   
107   
108   
109       /* check to see if we are using HA specific SP for a HA enabled server */
110       exec @retstat = sp_ha_check_certified 'sp_addserver', @HA_CERTIFIED
111       if (@retstat != 0)
112           return (1)
113   
114       /*
115       ** If we are logging this system procedure for replication,
116       ** we must be in the 'master' database to avoid creating a
117       ** multi-database transaction which could make recovery of
118       ** the 'master' database impossible.
119       */
120       select @master_is_rep = getdbrepstat(1)
121   
122       if (@master_is_rep < 0)
123       begin
124           /*
125           ** 18409, "The built-in function getdbrepstat() failed."
126           */
127           raiserror 18409, "getdbrepstat"
128           return (1)
129       end
130   
131       select @dbname = db_name()
132   
133       if (@master_is_rep > 0) and (@dbname != "master")
134       begin
135           /*
136           ** 18388, "You must be in the master database in order
137           ** to run '%1!'."
138           */
139           raiserror 18388, "sp_addserver"
140           return (1)
141       end
142   
143       /*
144       **  If we're in a transaction, disallow this since it might make recovery
145       **  impossible.
146       */
147       if @@trancount > 0
148       begin
149           /*
150           ** 17260, "Can't run %1! from within a transaction." 
151           */
152           raiserror 17260, "sp_addserver"
153           return (1)
154       end
155       else
156       begin
157           set chained off
158       end
159       set transaction isolation level 1
160   
161       /* check if user has sso role, proc_role will also do auditing
162       ** if required. proc_role will also print error message if required.
163       */
164       if (proc_role("sso_role") = 0)
165           return (1)
166   
167   
168       /*
169       **  Check to see that the @lname is valid.
170       */
171       if (@lname is not null)
172       begin
173           select @maxlen = length from master.dbo.syscolumns
174           where id = object_id("master.dbo.sysservers") and name = "srvname"
175   
176           if valid_name(@lname, @maxlen) = 0
177           begin
178               /*
179               ** 17240, "'" + @lname + "' is not a valid name." 
180               */
181               raiserror 17240, @lname
182               return (1)
183           end
184       end
185   
186       /*
187       **  Check to see that the @lname is valid name.
188       */
189       if (@lname is not null)
190       begin
191           if (@lname = "cluster" or @lname = "CLUSTER")
192           begin
193               /*
194               ** 17240, "'" + @lname + "' is not a valid name." 
195               */
196               raiserror 17240, @lname
197               return (1)
198           end
199       end
200   
201       /*
202       ** OMNI: See if we have a valid server class. If null, default to 'sql_server'.
203       */
204       if @class is null
205           select @class = "ASEnterprise"
206   
207       select @newclass = number
208       from master.dbo.spt_values
209       where type = 'X' and lower(name) = lower(@class)
210       if @@rowcount = 0
211       begin
212           /*
213           ** 17296, "Unknown server class '%1!'" 
214           */
215           raiserror 17296, @class
216           return (1)
217       end
218   
219       /*
220       ** to check if the server is a rtds provider
221       */
222       if @newclass in (12, 13, 14, 15)
223           select @isrtds = 1
224       else
225           select @isrtds = 0
226   
227       /*
228       **  Check to see that the @pname is valid.
229       */
230       if (@pname is NULL)
231           select @pname = @lname
232       else
233           /*
234           ** If the netname contains a colon, it's ok to use, as it may be in the form:
235           **
236           ** 	"hostname.domain.com:12345"	or
237           **	"hostname:12345"		or
238           **	"255.255.255.255:12345"
239           **
240           ** which is format for netname now supported by ctlib's CS_SERVERADDR connection 
241           ** property. Note that Omni converts colon to space before calling ct_con_props().
242           **
243           ** Note, IBM_MQ names (class == 13) don't have colons (:), but they have
244           ** parenthesis (()), so bypass the valid name check.
245           */
246   
247           select @maxlen = length from master.dbo.syscolumns
248           where id = object_id("master.dbo.sysservers") and name = "srvnetname"
249   
250       /*
251       ** If the name is SYB_BACKUP and netname is $dedicated or $roundrobin which is
252       ** Backup server policy to enable Multiple Backup server feature,
253       ** check for all Backup server entries in sysservers table.
254       */
255       if ((@lname = "SYB_BACKUP") and ((lower(@pname) = "$dedicated") or (lower(@pname) = "$roundrobin")))
256       begin
257           select @bs_flag = 0
258   
259           declare instancenames cursor for
260           select srvname from master..sysservers where srvstatus2 = 4
261   
262           open instancenames
263   
264           fetch instancenames into @bs_name
265   
266           while (@@sqlstatus = 0)
267           begin
268               select @bs_name = @bs_name + "_BS"
269               if not exists (select * from master..sysservers where srvname = @bs_name)
270               begin
271                   /*
272                   ** 19968, "Backup Server '%1!' is not configured in sysservers."
273                   */
274                   raiserror 19968, @bs_name
275                   select @bs_flag = 1
276               end
277               fetch instancenames into @bs_name
278           end
279           close instancenames
280   
281           if (@bs_flag = 1)
282           begin
283               /*
284               ** 19969, "Multiple Backup Server in Cluster can not be enabled."
285               */
286               raiserror 19969
287               return (1)
288           end
289       end
290   
291       /*
292       ** If the name is SYB_BACKUP and netname is $dedicated or $roundrobin which is
293       ** Backup server policy to enable Multiple Backup server feature,
294       ** allow the netname as specified keywords skipping valid_name() check.
295       */
296       if (not ((@lname = "SYB_BACKUP") and ((lower(@pname) = "$dedicated") or (lower(@pname) = "$roundrobin"))))
297       begin
298           if charindex(":", @pname) = 0 and valid_name(@pname, @maxlen) = 0 and @newclass != 13
299           begin
300               /*
301               ** 17240, "'" + @pname + "' is not a valid name." 
302               */
303               raiserror 17240, @pname
304               return (1)
305           end
306       end
307   
308       /*
309       ** If the server is rtds provider, check if it is registered in sysattributes
310       */
311       if (@isrtds = 1)
312           and (exists (select * from master.dbo.sysattributes
313                   where class = 21 and attribute = 10
314                       and object_type = 'PR'
315                       and object_cinfo = @lname))
316           select @insysattributes = 1
317       else
318           select @insysattributes = 0
319   
320       /*
321       **  Server names must be unique so check.  If a server already exists with
322       **  this logical _and_ physical name, the server already exists, so there's
323       **  no work to do.  However, if the logical name exists but the physical
324       **  names differ, this will be an update to the table to change the physical
325       **  name.
326       */
327       if exists (select *
328               from master.dbo.sysservers
329               where srvname = @lname)
330       begin
331           if (@isrtds = 0) or (@insysattributes = 0)
332           begin
333               select @srvclass = srvclass,
334                   @srvid = srvid,
335                   @netname = isnull(srvnetname, @lname)
336               from master.dbo.sysservers
337               where srvname = @lname
338           end
339           else
340           begin
341               select @srvclass = int_value,
342                   @srvid = object,
343                   @netname = isnull(char_value, @lname)
344               from master.dbo.sysattributes
345               where class = 21 and attribute = 10
346                   and object_type = 'PR'
347                   and object_cinfo = @lname
348           end
349   
350           /*
351           ** 17290, "There is already a server named '%1!', physical name '%2!'."
352           */
353           if (@netname = @pname AND @srvclass = @newclass)
354           begin
355               raiserror 17290, @lname, @pname
356               return (1)
357           end
358   
359           if (@isrtds = 0) and (@srvclass in (12, 13, 14, 15))
360               select @leavertds = 1
361           else
362               select @leavertds = 0
363   
364           /* 
365           ** This transaction also writes a log record for replicating the
366           ** invocation of this procedure. If logexec() fails, the transaction
367           ** is aborted.
368           **
369           ** IMPORTANT: The name rs_logexec is significant and is used by
370           ** Adaptive Server.
371           */
372           begin tran rs_logexec
373   
374   
375   
376           if (@isrtds = 1) or (@leavertds = 1)
377               begin tran rtds_dyn
378   
379           if (@leavertds = 1)
380           begin
381               delete from master.dbo.sysattributes
382               where class = 21 and attribute = 10
383                   and object_type = 'PR' and object_cinfo = @lname
384               if (@@error != 0)
385                   goto clean_all
386           end
387   
388           if (@isrtds = 1)
389           begin
390               if (@insysattributes = 1)
391                   update master.dbo.sysattributes
392                   set char_value = @pname, int_value = @newclass
393                   where class = 21 and attribute = 10
394                       and object_type = 'PR'
395                       and object_cinfo = @lname
396               else
397                   insert master.dbo.sysattributes
398                   (class, attribute, object_type, object_cinfo,
399                       object, int_value, char_value)
400                   values (21, 10, 'PR', @lname, @srvid, @newclass,
401                       @pname)
402               if (@@error != 0)
403                   goto clean_all
404           end
405   
406   
407   
408           /*
409           ** 17294, "Changing physical name of server '%1!' from '%2!' to '%3!'"
410           */
411           if (@netname != @pname)
412           begin
413               update master.dbo.sysservers
414               set srvnetname = @pname
415               where srvname = @lname
416   
417               if (@@error != 0)
418               begin
419                   goto clean_all
420               end
421   
422   
423   
424               /* Suppress the Msg only for SYB_HACMP changes for netname */
425               if @lname != "SYB_HACMP"
426               begin
427                   exec sp_getmessage 17294, @msg output
428                   print @msg, @lname, @netname, @pname
429               end
430           end
431   
432           /*
433           ** 17297, Changing server class of server '%1!' from '%2!' to '%3!'
434           */
435           if (@srvclass != @newclass)
436           begin
437               select @oldclass = name
438               from master.dbo.spt_values
439               where type = 'X' and number = @srvclass
440               if @@rowcount = 0
441               begin
442                   select @oldclass = "unknown"
443               end
444   
445               if lower(@class) = "local"
446               begin
447                   /*
448                   ** 19971, "You cannot change the server class of
449                   ** existing server '%1!' from '%2!' to '%3!'."
450                   */
451                   raiserror 19971, @lname, @oldclass, @class
452                   goto clean_all
453               end
454   
455               update master.dbo.sysservers
456               set srvclass = @newclass
457               where srvname = @lname
458   
459               if (@@error != 0)
460               begin
461                   goto clean_all
462               end
463   
464   
465               exec sp_getmessage 17297, @msg output
466               print @msg, @lname, @oldclass, @class
467           end
468   
469           if (@isrtds = 1) or (@leavertds = 1)
470               commit tran rtds_dyn
471           /*
472           ** For SDC, update cluster-wide in-memory SRVDES with data from
473           ** just-updated SYSSERVERS table. Before dbcc cis, the dbcc
474           ** command scope needs to be set to cluster.
475           */
476           if (@@clustermode = "shared disk cluster")
477           begin
478               select @scope = NULL
479               select @outstr = "dbcc set_scope_in_cluster('scope')"
480               if (charindex("instance", @outstr) != 0)
481               begin
482                   /* save the scope to be restored later */
483                   select @scope = "instance"
484                   dbcc set_scope_in_cluster('cluster')
485               end
486           end
487   
488           dbcc cis("srvdes", @srvid)
489   
490           /* restore dbcc command scope */
491           if (@@clustermode = "shared disk cluster")
492           begin
493               if (@scope = "instance")
494               begin
495                   dbcc set_scope_in_cluster('instance')
496               end
497           end
498   
499   
500   
501           goto commit_all
502       end
503   
504       /*
505       ** Check to see that the server class is unique for the EJB class
506       */
507       select @dupsrvclass = srvclass
508       from master.dbo.sysservers
509       where srvclass = 10 and @class = "ASEJB"
510   
511       if @@rowcount >= 1
512       begin
513           /*
514           ** 18887, "Cannot have more than one physical or logical server 
515           ** entry for the ASEJB class."
516           */
517           raiserror 18887
518           goto clean_all
519       end
520   
521       /* 
522       ** If the server is of the class ASEJB, set the default status to 1024 which
523       ** indicates that the 'external engine auto start option would be enabled
524       ** for such class of servers
525       */
526       if @class = "ASEJB"
527       begin
528           select @dflt_status = number from master.dbo.spt_values
529           where type = "A" and name = "external engine auto start"
530           select @dflt_status = @dflt_status + number from master.dbo.spt_values
531           where type = "A" and name = "no timeouts"
532       end
533       else
534       begin
535           /*
536           ** retrieve the value of the default security setting, namely
537           ** RPC security model A
538           */
539           select @dflt_status = number from master.dbo.spt_values
540           where type = "A" and name = "rpc security model A"
541   
542           select @dflt_status = @dflt_status + number from master.dbo.spt_values
543           where type = "A" and name = "no timeouts"
544       end
545   
546       /*
547       ** Default is for non-relocateable joins
548       */
549       select @dflt_status2 = 0
550   
551       /*
552       ** Default values for srvstatus2 
553       **
554       **		OPTION			VALUE	BIT
555       **		~~~~~~			~~~~~	~~~
556       **	enable login redirection	ON	0x00000002
557       **	cluster instance 		OFF	0x00000004
558       */
559       select @dflt_status2 = 2
560   
561       /*
562       **  If this is not the local server, then its srvid = max(srvid) + 1.
563       */
564       if lower(@class) != "local"
565       begin
566   
567           /*
568           ** 17295, "Adding server '%1!', physical name '%2!'"
569           */
570           exec sp_getmessage 17295, @msg output
571           print @msg, @lname, @pname
572   
573   
574   
575   
576           select @srvid = isnull(max(srvid), 0) + 1
577           from master.dbo.sysservers where srvid != 999
578   
579           /*
580           ** Set the default cost for remote servers
581           */
582           select @srvcost = 1000
583   
584   
585           if (@isrtds = 1)
586               begin tran rtds_dyn
587           if (@backupejbflag = 1)
588           begin
589               insert into master.dbo.sysservers
590               (srvid, srvstatus, srvname, srvnetname, srvclass, srvcost, srvstatus2)
591               values (@remotesrvid, @dflt_status, @lname, @pname, @newclass, @srvcost, @dflt_status2)
592           end
593           else
594           begin
595               insert into master.dbo.sysservers
596               (srvid, srvstatus, srvname, srvnetname, srvclass, srvcost, srvstatus2)
597               values (@srvid, @dflt_status, @lname, @pname, @newclass, @srvcost, @dflt_status2)
598               if (@@error != 0)
599                   goto clean_all
600               if (@isrtds = 1)
601               begin
602                   if (@insysattributes = 1)
603                   begin
604                       update master.dbo.sysattributes
605                       set int_value = @newclass, char_value = @pname,
606                           object = @srvid
607                       where class = 21 and attribute = 10
608                           and object_type = 'PR'
609                           and object_cinfo = @lname
610                   end
611                   else
612                   begin
613                       insert master.dbo.sysattributes
614                       (class, attribute, object_type, object_cinfo,
615                           object, int_value, char_value)
616                       values (21, 10, 'PR', @lname, @srvid, @newclass, @pname)
617                   end
618                   if (@@error != 0)
619                       goto clean_all
620                   commit tran rtds_dyn
621               end
622           end
623   
624   
625   
626   
627       end
628   
629       /*
630       **  If @class = "local" then this is the local server and it's
631       **  srvid = 0.
632   
633       */
634       else
635       begin
636           if lower(@class) != "local"
637           begin
638               /*
639               ** 17291, "Usage: sp_addserver servername [, 'local | NULL'],
640               **	   [, physical_name]"
641               */
642               raiserror 17291
643               goto clean_all
644           end
645   
646           if exists (select *
647                   from master.dbo.sysservers
648                   where srvid = 0)
649           begin
650               /*
651               ** 17292, "There is already a local server."
652               */
653               raiserror 17292
654               goto clean_all
655           end
656   
657           if (@@clustermode = "shared disk cluster")
658           begin
659               if @lname != @@clustername
660               begin
661                   /*
662                   ** 19972, "Local server must use the cluster name as the server name."
663                   */
664                   raiserror 19972
665                   goto clean_all
666               end
667           end
668   
669           /*
670           ** 17295, "Adding server '%1!', physical name '%2!'"
671           */
672           exec sp_getmessage 17295, @msg output
673           print @msg, @lname, @pname
674   
675   
676   
677           insert into master.dbo.sysservers
678           (srvid, srvstatus, srvname, srvnetname, srvclass, srvcost, srvstatus2)
679           values (0, @dflt_status, @lname, @pname, 0, 0, @dflt_status2)
680   
681       end
682   
683   
684       /*
685       ** log the command for replication support
686       */
687       if (@master_is_rep > 0)
688       begin
689           if (logexec(1) != 1)
690           begin
691               /*
692               ** , "17869 Stored procedure %1 failed'
693               **       because '%2' failed in database '%3'."
694               */
695               raiserror 17869, "sp_addserver", "logexec()", @dbname
696               goto clean_all
697           end
698       end
699   
700       /*
701       ** 17293, "Server added."
702       */
703       exec sp_getmessage 17293, @msg output
704       print @msg
705   
706   commit_all:
707       commit tran rs_logexec
708       return (0)
709   
710   
711   clean_all:
712       if (@isrtds = 1) or (@leavertds = 1)
713           rollback tran rtds_dyn
714   
715       rollback tran rs_logexec
716       return (1)
717   


exec sp_procxmode 'sp_addserver', 'AnyMode'
go

Grant Execute on sp_addserver to public
go
DEFECTS
 MCTR 4 Conditional Begin Tran or Commit Tran 372
 MCTR 4 Conditional Begin Tran or Commit Tran 377
 MCTR 4 Conditional Begin Tran or Commit Tran 470
 MCTR 4 Conditional Begin Tran or Commit Tran 586
 MCTR 4 Conditional Begin Tran or Commit Tran 620
 MINU 4 Unique Index with nullable columns master..sysattributes master..sysattributes
 MTYP 4 Assignment type mismatch @newclass: smallint = int 207
 MTYP 4 Assignment type mismatch @srvclass: smallint = int 341
 MTYP 4 Assignment type mismatch @srvid: smallint = int 342
 MTYP 4 Assignment type mismatch @dflt_status: smallint = int 528
 MTYP 4 Assignment type mismatch @dflt_status: smallint = int 539
 MTYP 4 Assignment type mismatch srvname: varchar(30) = varchar(255) 591
 MTYP 4 Assignment type mismatch srvstatus2: uint = int 591
 MTYP 4 Assignment type mismatch srvname: varchar(30) = varchar(255) 597
 MTYP 4 Assignment type mismatch srvstatus2: uint = int 597
 MTYP 4 Assignment type mismatch srvname: varchar(30) = varchar(255) 679
 MTYP 4 Assignment type mismatch srvstatus2: uint = int 679
 QPUI 4 Join or Sarg with Un-Rooted Partial Index Use SARG Candidate index: spt_values.spt_valuesclust clustered
(number, type)
Intersection: {type}
209
 QPUI 4 Join or Sarg with Un-Rooted Partial Index Use SARG Candidate index: spt_values.spt_valuesclust clustered
(number, type)
Intersection: {type}
529
 QPUI 4 Join or Sarg with Un-Rooted Partial Index Use SARG Candidate index: spt_values.spt_valuesclust clustered
(number, type)
Intersection: {type}
531
 QPUI 4 Join or Sarg with Un-Rooted Partial Index Use SARG Candidate index: spt_values.spt_valuesclust clustered
(number, type)
Intersection: {type}
540
 QPUI 4 Join or Sarg with Un-Rooted Partial Index Use SARG Candidate index: spt_values.spt_valuesclust clustered
(number, type)
Intersection: {type}
543
 QTYP 4 Comparison type mismatch Comparison type mismatch: uint vs int 260
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 313
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 345
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 382
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 393
 QTYP 4 Comparison type mismatch Comparison type mismatch: int vs smallint 439
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 509
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 577
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 607
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 648
 TNOU 4 Table with no unique index master..spt_values master..spt_values
 VRUN 4 Variable is read and not initialized @remotesrvid 591
 CUNU 3 Cursor not updated: cursor should contain 'for read only' clause instancenames 260
 MGTP 3 Grant to public master..spt_values  
 MGTP 3 Grant to public master..sysattributes  
 MGTP 3 Grant to public master..syscolumns  
 MGTP 3 Grant to public master..sysservers  
 MGTP 3 Grant to public sybsystemprocs..sp_addserver  
 MNER 3 No Error Check should check @@error after update 391
 MNER 3 No Error Check should check @@error after insert 397
 MNER 3 No Error Check should check return value of exec 427
 MNER 3 No Error Check should check return value of exec 465
 MNER 3 No Error Check should check return value of exec 570
 MNER 3 No Error Check should check @@error after insert 589
 MNER 3 No Error Check should check @@error after update 604
 MNER 3 No Error Check should check @@error after insert 613
 MNER 3 No Error Check should check return value of exec 672
 MNER 3 No Error Check should check @@error after insert 677
 MNER 3 No Error Check should check return value of exec 703
 MUCO 3 Useless Code Useless Brackets 111
 MUCO 3 Useless Code Useless Brackets 112
 MUCO 3 Useless Code Useless Brackets 122
 MUCO 3 Useless Code Useless Brackets 128
 MUCO 3 Useless Code Useless Brackets 140
 MUCO 3 Useless Code Useless Brackets 153
 MUCO 3 Useless Code Useless Brackets 164
 MUCO 3 Useless Code Useless Brackets 165
 MUCO 3 Useless Code Useless Brackets 171
 MUCO 3 Useless Code Useless Brackets 182
 MUCO 3 Useless Code Useless Brackets 189
 MUCO 3 Useless Code Useless Brackets 191
 MUCO 3 Useless Code Useless Brackets 197
 MUCO 3 Useless Code Useless Brackets 216
 MUCO 3 Useless Code Useless Brackets 230
 MUCO 3 Useless Code Useless Brackets 255
 MUCO 3 Useless Code Useless Brackets 266
 MUCO 3 Useless Code Useless Brackets 281
 MUCO 3 Useless Code Useless Brackets 287
 MUCO 3 Useless Code Useless Brackets 296
 MUCO 3 Useless Code Useless Brackets 304
 MUCO 3 Useless Code Useless Brackets 353
 MUCO 3 Useless Code Useless Brackets 356
 MUCO 3 Useless Code Useless Brackets 379
 MUCO 3 Useless Code Useless Brackets 384
 MUCO 3 Useless Code Useless Brackets 388
 MUCO 3 Useless Code Useless Brackets 390
 MUCO 3 Useless Code Useless Brackets 402
 MUCO 3 Useless Code Useless Brackets 411
 MUCO 3 Useless Code Useless Brackets 417
 MUCO 3 Useless Code Useless Brackets 435
 MUCO 3 Useless Code Useless Brackets 459
 MUCO 3 Useless Code Useless Brackets 476
 MUCO 3 Useless Code Useless Brackets 480
 MUCO 3 Useless Code Useless Brackets 491
 MUCO 3 Useless Code Useless Brackets 493
 MUCO 3 Useless Code Useless Brackets 585
 MUCO 3 Useless Code Useless Brackets 587
 MUCO 3 Useless Code Useless Brackets 598
 MUCO 3 Useless Code Useless Brackets 600
 MUCO 3 Useless Code Useless Brackets 602
 MUCO 3 Useless Code Useless Brackets 618
 MUCO 3 Useless Code Useless Brackets 657
 MUCO 3 Useless Code Useless Brackets 687
 MUCO 3 Useless Code Useless Brackets 689
 MUCO 3 Useless Code Useless Brackets 708
 MUCO 3 Useless Code Useless Brackets 716
 MUPK 3 Update column which is part of a PK or unique index object 605
 QAFM 3 Var Assignment from potentially many rows 173
 QAFM 3 Var Assignment from potentially many rows 207
 QAFM 3 Var Assignment from potentially many rows 247
 QAFM 3 Var Assignment from potentially many rows 341
 QAFM 3 Var Assignment from potentially many rows 437
 QAFM 3 Var Assignment from potentially many rows 507
 QAFM 3 Var Assignment from potentially many rows 528
 QAFM 3 Var Assignment from potentially many rows 530
 QAFM 3 Var Assignment from potentially many rows 539
 QAFM 3 Var Assignment from potentially many rows 542
 QISO 3 Set isolation level 159
 QIWC 3 Insert with not all columns specified missing 8 columns out of 15 398
 QIWC 3 Insert with not all columns specified missing 2 columns out of 9 590
 QIWC 3 Insert with not all columns specified missing 2 columns out of 9 596
 QIWC 3 Insert with not all columns specified missing 8 columns out of 15 614
 QIWC 3 Insert with not all columns specified missing 2 columns out of 9 678
 QPNC 3 No column in condition 509
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {id}
174
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {id}
248
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {object_type, object_cinfo, attribute, class}
313
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {object_type, object_cinfo, attribute, class}
345
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {object_type, object_cinfo, attribute, class}
382
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {object_type, object_cinfo, attribute, class}
393
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysattributes.csysattributes unique clustered
(class, attribute, object_type, object, object_info1, object_info2, object_info3, object_cinfo)
Intersection: {object_type, object_cinfo, attribute, class}
607
 QSWV 3 Sarg with variable @srvclass, Candidate Index: spt_values.spt_valuesclust clustered(number, type) F 439
 VNRD 3 Variable is not read @dupsrvclass 507
 VUNU 3 Variable is not used @end_code 88
 CUPD 2 Updatable Cursor Marker (updatable by default) 260
 MSUB 2 Subquery Marker 269
 MSUB 2 Subquery Marker 312
 MSUB 2 Subquery Marker 327
 MSUB 2 Subquery Marker 646
 MTR1 2 Metrics: Comments Ratio Comments: 46% 66
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 80 = 88dec - 10exi + 2 66
 MTR3 2 Metrics: Query Complexity Complexity: 339 66

DEPENDENCIES
PROCS AND TABLES USED
reads table master..spt_values (1)  
read_writes table master..sysservers (1)  
calls proc sybsystemprocs..sp_ha_check_certified  
   reads table tempdb..sysobjects (1)  
read_writes table master..sysattributes (1)  
reads table master..syscolumns (1)  
calls proc sybsystemprocs..sp_getmessage  
   calls proc sybsystemprocs..sp_validlang  
      reads table master..syslanguages (1)  
   reads table sybsystemprocs..sysusermessages  
   reads table master..sysmessages (1)  
   reads table master..syslanguages (1)