1 /** This part copied from Sybase test **/
3 /* Script generated by dbschema.pl(2.4.2) on Mon Aug 18 14:15:25 2003. */
4 /* Script extracted on a solaris system. */
11 /* No groups found. */
16 exec sp_adduser 'guest', 'guest'
17 exec sp_adduser 'probe', 'probe'
22 /* No aliases found. */
24 /* Add user-defined data types: */
26 /* No user defined types found. */
35 /* No defaults found. */
36 /* Bind rules & defaults to user data types... */
38 /* No defaults to bind. */
40 /* No rules to bind. */
43 /* Start of description of table dbo.jdbc_function_escapes */
48 CREATE TABLE dbo.jdbc_function_escapes (
49 escape_name varchar(40) NOT NULL,
50 map_string varchar(40) NOT NULL
55 /* Add permissions for table... */
56 IF OBJECT_ID('dbo.jdbc_function_escapes') IS NOT NULL
58 GRANT SELECT ON dbo.jdbc_function_escapes TO public
62 /* Bind rules & defaults to columns... */
63 /* End of description of table dbo.jdbc_function_escapes */
66 /* Start of description of table dbo.spt_jdbc_conversion */
71 CREATE TABLE dbo.spt_jdbc_conversion (
72 datatype int NOT NULL,
73 conversion char(20) NOT NULL
78 /* Add permissions for table... */
79 IF OBJECT_ID('dbo.spt_jdbc_conversion') IS NOT NULL
81 GRANT SELECT ON dbo.spt_jdbc_conversion TO public
85 /* Bind rules & defaults to columns... */
86 /* End of description of table dbo.spt_jdbc_conversion */
89 /* Start of description of table dbo.spt_jdbc_table_types */
94 CREATE TABLE dbo.spt_jdbc_table_types (
95 TABLE_TYPE char(15) NOT NULL
100 /* Add permissions for table... */
101 IF OBJECT_ID('dbo.spt_jdbc_table_types') IS NOT NULL
103 GRANT SELECT ON dbo.spt_jdbc_table_types TO public
107 /* Bind rules & defaults to columns... */
108 /* End of description of table dbo.spt_jdbc_table_types */
111 /* Start of description of table dbo.spt_jtext */
116 CREATE TABLE dbo.spt_jtext (
117 mdinfo varchar(30) NOT NULL,
124 /* Add permissions for table... */
125 IF OBJECT_ID('dbo.spt_jtext') IS NOT NULL
127 GRANT SELECT ON dbo.spt_jtext TO public
131 /* Bind rules & defaults to columns... */
132 /* End of description of table dbo.spt_jtext */
135 /* Start of description of table dbo.spt_limit_types */
140 CREATE TABLE dbo.spt_limit_types (
141 name char(30) NOT NULL,
142 id smallint NOT NULL,
143 enforced tinyint NOT NULL,
144 object_type smallint NOT NULL,
145 scope smallint NOT NULL,
146 units char(60) NOT NULL
151 /* Add permissions for table... */
152 IF OBJECT_ID('dbo.spt_limit_types') IS NOT NULL
154 GRANT SELECT ON dbo.spt_limit_types TO public
158 /* Bind rules & defaults to columns... */
159 /* End of description of table dbo.spt_limit_types */
162 /* Start of description of table dbo.spt_mda */
167 CREATE TABLE dbo.spt_mda (
168 mdinfo varchar(30) NOT NULL,
169 querytype tinyint NOT NULL,
170 query varchar(255) NULL,
171 mdaver_start tinyint NOT NULL,
172 mdaver_end tinyint NOT NULL,
173 srvver_start int NOT NULL,
174 srvver_end int NOT NULL
179 IF OBJECT_ID('dbo.spt_mda') IS NOT NULL
181 CREATE UNIQUE NONCLUSTERED INDEX spt_mda_ind
182 ON spt_mda (mdinfo, mdaver_end, srvver_end)
187 /* Add permissions for table... */
188 IF OBJECT_ID('dbo.spt_mda') IS NOT NULL
190 GRANT SELECT ON dbo.spt_mda TO public
194 /* Bind rules & defaults to columns... */
195 /* End of description of table dbo.spt_mda */
198 /* Start of description of table dbo.spt_monitor */
203 CREATE TABLE dbo.spt_monitor (
204 lastrun datetime NOT NULL,
205 cpu_busy int NOT NULL,
206 io_busy int NOT NULL,
208 pack_received int NOT NULL,
209 pack_sent int NOT NULL,
210 connections int NOT NULL,
211 pack_errors int NOT NULL,
212 total_read int NOT NULL,
213 total_write int NOT NULL,
214 total_errors int NOT NULL
220 /* Add permissions for table... */
221 IF OBJECT_ID('dbo.spt_monitor') IS NOT NULL
223 GRANT SELECT ON dbo.spt_monitor TO public
227 /* Bind rules & defaults to columns... */
228 /* End of description of table dbo.spt_monitor */
231 /* Start of description of table dbo.syblicenseslog */
236 CREATE TABLE dbo.syblicenseslog (
237 status smallint NOT NULL,
238 logdate datetime NOT NULL,
239 maxlicenses int NOT NULL
244 /* Add permissions for table... */
245 /* Bind rules & defaults to columns... */
246 /* End of description of table dbo.syblicenseslog */
249 /* Now create the key definitions ...*/
257 /* No views found. */
261 /* Procedure sp_configure, owner dbo */
266 /* Sccsid = "%Z% generic/sproc/%M% %I% %G%" */
267 /* 4.8 1.1 06/14/90 sproc/src/configure */
270 ** Messages for "sp_configure" 17410
271 ** Must use "langid" when referencing spt_values
273 ** 17260, "Can't run %1! from within a transaction."
274 ** 17410, "Configuration option doesn't exist."
275 ** 17411, "Configuration option is not unique."
276 ** 17413, "The value of the 'number of devices' must be greater than the highest VDEVNO, '%1!', defined in sysdevices."
277 ** 17414, "You can't set the default language to a language ID that is not defined in Syslanguages."
278 ** 17415, "Configuration option value is not legal."
279 ** 17418, "'%1!' is an invalid file command. The valid commands are 'verify', 'read', 'write', and 'restore'."
280 ** 17419, "Configuration option changed. The SQL Server need not be rebooted since the option is dynamic.
281 ** 18123, "Configuration option changed. The SQL Server must be rebooted before the change in effect since the option is static."
282 ** 18124, "No matching configuration options. Here is a listing of groups:"
283 ** 18125, "Must provide the parameter 'filename'."
284 ** 18133, "The character set, '%1!', is invalid since it is not defined in Syscharsets."
285 ** 18134, "The sortorder, '%1!', is invalid since it is not defined in Syscharsets."
286 ** 18549, "Invalid third argument supplied: '%1!'. Valid choices are
287 ** 'with truncate' or 'default'."
289 create procedure sp_configure
290 @configname varchar(80) = NULL, /* configure option name */
291 @configvalue int = NULL, /* configure value */
292 @configvalue2 varchar(255) = NULL, /* config file command/charset info */
293 @configvalue3 varchar(255) = NULL /* physical name of file */
296 declare @confignum int /* number of option to be configured */
297 declare @configcount int /* number of options like @configname */
298 declare @whichone int /* using english or default lang ? */
299 declare @cmd smallint /* configuration file command */
300 declare @status int /* return status for misc calls */
301 declare @children int /* number of children in a group */
302 declare @parent int /* config number of parent group */
303 declare @msg varchar(255) /* temp buffer for messages */
304 declare @sysconfig smallint /* contents of sysconfigures.config */
305 declare @sysname varchar(255) /* contents of sysconfigures.comment */
306 declare @sysparent smallint /* contents of sysconfigures.parent */
307 declare @sysstatus smallint /* contents of sysconfigures.status */
308 declare @value int /* default charset/sort order id */
309 declare @user_displaylevel int /* user display level */
310 declare @maxvdevno int /* highest number of vdevno */
311 declare @sortorder_id int /* current sortorder id */
312 declare @charset_id int /* current charset id */
313 declare @use_wildcard tinyint /* use wildcard to search option name or not */
314 declare @match_count int /* number of option found by name match */
315 declare @cache_part_temp int /* cache partition number */
316 declare @partition_number int /* cache partition number */
317 declare @cmpstate int /* Local NODE state in companionship */
318 declare @nocase tinyint /* case-sensitive sort order flag */
324 select @user_displaylevel = NULL
325 select @sortorder_id =
326 value from master.dbo.syscurconfigs where config = 123
328 value from master.dbo.syscurconfigs where config = 131
330 select @use_wildcard = 1
333 ** Check if the default sort order is case-insensitive.
341 ** Disallow running sp_configure within a transaction since it might make
342 ** recovery impossible.
347 ** 17260, "Can't run %1! from within a transaction."
349 raiserror 17260, "sp_configure"
357 set transaction isolation level 1
361 ** If the "default sortorder" is case insensitive dictionary sort order,
362 ** the procedure will just print out all the options and their values
363 ** without grouping if no option name is given.
365 if (@nocase = 1 and @configname is NULL)
367 select "Parameter Name" = convert(char(30), name),
368 "Default" = convert(char(11), space(11-char_length(
369 convert(varchar(11), defvalue)))+
370 convert(varchar(11), defvalue)),
371 "Memory Used" = convert(char(11), space(11-char_length(
372 convert(varchar(11), b.comment)))+
373 convert(varchar(11), b.comment)),
374 "Config Value" =convert(char(11), space(11-char_length(
375 isnull(a.value2, convert(char(32), a.value)))) +
376 isnull(a.value2, convert(char(32), a.value))),
377 "Run Value" = convert(char(11), space(11-char_length(
378 isnull(b.value2, convert(char(32), b.value)))) +
379 isnull(b.value2, convert(char(32), b.value)))
380 from master.dbo.sysconfigures a,
381 master.dbo.syscurconfigs b
391 /* Validate the configname if it not NULL */
392 if @configname is not NULL
394 select @configcount = count(*)
395 from master.dbo.sysconfigures
396 where name like "%" + @configname + "%"
400 ** If configure option is not unique and case-insensitive
401 ** dictionary sort order is used, check if unique option found
402 ** by exact name match, if so, then disable wildcard match
403 ** for searching option name.
405 if (@configcount > 1 and @nocase = 1)
407 /* check if unique option found by exact name match */
408 select @match_count = count(*)
409 from master.dbo.sysconfigures
410 where name = @configname
414 select @use_wildcard = 0 /* don't use wildcard */
415 select @configcount = @match_count
420 ** If more than one option like @configname,
421 ** show the duplicates and return.
426 ** 17411, "Configuration option is not unique."
431 select "Parameter Name" = convert(char(30), name),
432 "Default" = convert(char(11), space(11-char_length(
433 convert(varchar(11), defvalue)))+
434 convert(varchar(11), defvalue)),
435 "Memory Used" = convert(char(11), space(11-char_length(
436 convert(varchar(11), b.comment)))+
437 convert(varchar(11), b.comment)),
438 "Config Value" =convert(char(11), space(11-char_length(
439 isnull(a.value2, convert(char(32), a.value)))) +
440 isnull(a.value2, convert(char(32), a.value))),
441 "Run Value" = convert(char(11), space(11-char_length(
442 isnull(b.value2, convert(char(32), b.value)))) +
443 isnull(b.value2, convert(char(32), b.value)))
444 from master.dbo.sysconfigures a,
445 master.dbo.syscurconfigs b
448 and name like "%" + @configname + "%"
457 ** if it is a valid option and the @configvalue is not NULL,
460 if (@configcount != 0) and (@configvalue is not NULL)
463 select @confignum = config,
465 from master.dbo.sysconfigures
466 where name like "%" + @configname + "%"
471 ** If @configvalue2 is "default",
472 ** setting the value to default
474 if (@configvalue2 = "default")
480 ** If the option name is "configuration file"
485 ** if the file command is one of the valid
488 if ((@configvalue2 = "read") or
489 (@configvalue2 = "write") or
490 (@configvalue2 = "restore") or
491 (@configvalue2 = "verify"))
494 ** if filename is NULL
496 if (@configvalue3 is NULL)
498 /* 18125, "Must provide the parameter 'filename'." */
503 ** Must have sa_role to run these
506 if (proc_role("sa_role") < 1)
512 if (@configvalue2 = "verify")
515 if (@configvalue2 = "read")
518 if (@configvalue2 = "write")
521 if (@configvalue2 = "restore")
528 ** print the message to show the valid
531 raiserror 17418, @configvalue2
535 select @status = config_admin(@cmd,0,0,0,NULL,
550 /* get current default charset id */
551 select @value = value from
552 master.dbo.sysconfigures
555 if @configvalue2 is not NULL
557 /* validate the charset id */
558 if not exists (select *
559 from master..syscharsets
560 where name = @configvalue2
561 and type between 1000 and 1999)
564 /* 18133, "The character set, '%1!', is invalid since it
565 ** is not defined in Syscharsets."
567 raiserror 18133, @configvalue2
571 /* get default charset id from name */
573 from master..syscharsets
574 where name = @configvalue2
575 and type between 1000 and 1999
581 /* get current default sortord id */
582 select @value = value from
583 master.dbo.sysconfigures
586 if @configvalue2 is not NULL
588 /* validate the sortord id */
589 if not exists (select *
590 from master..syscharsets
591 where name = @configvalue2
592 and type between 2000 and 2999)
594 /* 18134, "The sortorder, '%1!', is invalid since it
595 ** is not defined in Syscharsets."
597 raiserror 18134, @configvalue2
601 /* get default sortorder id from name */
603 from master..syscharsets
604 where name = @configvalue2
605 and type between 2000 and 2999
610 ** If an attempt to enable a disk mirroring is made, and
611 ** if this happens to be a server with HA services turned
612 ** on, we disallow. Currently we do not support ASE HA
613 ** services along with sybase mirroring.
615 if (@confignum = 140 and @configvalue = 0)
617 select @cmpstate = @@cmpstate
620 /* 18816 Mirroring not allowed in ASE HA */
627 ** If an attempt to disable disk mirroring is being made,
628 ** ensure that there are no devices that are currently
632 if (@confignum = 140 and @configvalue = 1)
634 if (select count(*) from master.dbo.sysdevices
635 where status & 512 = 512) > 0
638 /* 18750, Unable to disable disk mirroring
639 ** because some devices are currently
640 ** mirrored. Use 'disk unmirror' to
641 ** unmirror these devices and then
642 ** re-run this sp_configure command.
651 ** If this is the number of devices configuration
652 ** parameter, we want to make sure that it's not being
653 ** set to lower than the
654 ** number of devices in sysdevices.
659 ** Get the default value if trying to set the
660 ** value to the default value
664 select @configvalue = convert(int, defvalue)
665 from master.dbo.syscurconfigs
670 ** Get the max vdevno.
672 select @maxvdevno = max(
674 substring(convert(binary(4), d.low),
676 from master.dbo.sysdevices d,
677 master.dbo.spt_values v
679 if (@configvalue <= @maxvdevno)
681 /* 17413, "The value of the 'number of devices' must be
682 ** greater than the highest VDEVNO, '%1!', defined
685 raiserror 17413, @maxvdevno
692 ** If this is the number of default language, we want
693 ** to make sure that the new value is a valid language
694 ** id in Syslanguages.
698 if not exists (select *
699 from master.dbo.syslanguages
700 where langid = @configvalue)
702 /* 0 is default language, us_english */
705 /* 17414, "You can't set the default language to a
706 ** language ID that is not defined in Syslanguages."
715 ** If this is the number of current audit table we want
716 ** to make sure that if "with truncate" opiton is not
717 ** provided new table is empty other wise fail.
721 if @configvalue2 is not NULL
723 if (@configvalue2 not in ("with truncate",
727 ** 18549, "Invalid third argument
728 ** supplied: '%1!'. Valid
729 ** choices are 'with truncate'
732 raiserror 18549, @configvalue2
744 if @configvalue is not NULL
746 if (@configvalue2 = "default")
748 select @partition_number = 1
752 select @partition_number =
756 if (@partition_number <= 0) OR
757 (@partition_number > 64)
763 select @cache_part_temp = 2
764 while @cache_part_temp < @partition_number
765 select @cache_part_temp =
767 if @partition_number != 1 AND
768 @cache_part_temp != @partition_number
776 /* call config_admin() to set the new value */
777 select @status = config_admin(@cmd, @confignum,
778 @configvalue, @value, NULL, @configvalue2)
783 /* Display the new value */
784 select "Parameter Name" = convert(char(30), name),
785 "Default" = convert(char(11), space(11-char_length(
786 convert(varchar(11), defvalue))) +
787 convert(varchar(11), defvalue)),
788 "Memory Used" = convert(char(11),space(11-char_length(
789 convert(varchar(11), c.comment))) +
790 convert(varchar(11), c.comment)),
791 "Config Value" = convert(char(11),
792 space(11-char_length(
793 isnull(b.value2, convert(char(32), b.value)))) +
794 isnull(b.value2, convert(char(32), b.value))),
795 "Run Value" = convert(char(11), space(11-char_length(
796 isnull(c.value2, convert(char(32), c.value)))) +
797 isnull(c.value2, convert(char(32), c.value)))
798 from master.dbo.sysconfigures b,
799 master.dbo.syscurconfigs c
801 b.config = @confignum and
805 ** print reboot message if this option is not
808 select @sysstatus = @sysstatus & 8
811 exec sp_getmessage 17419, @msg output
816 exec sp_getmessage 18123, @msg output
828 ** @configcount=0 implies @configname is not valid
829 ** @configname=NULL implies displaying all the parameters except for
830 ** the parameters with the config number equal to 19 or the parent equal
831 ** to 19 since those parameters are displayed by sp_cacheconfig.
835 /* 18124, "No matching configuration options.
836 ** Here is a listing of groups:"
839 select convert(char(50), name)
840 from master.dbo.sysconfigures
847 else if (@configname is NULL)
848 select @configname = "Config"
851 ** retrieve the display level from sysattributes
853 select @user_displaylevel = int_value from master.dbo.sysattributes where
856 object_type = 'L' AND
860 ** set the default display level to 10 if it is not defined in sysattributes
862 if (@user_displaylevel = NULL)
863 select @user_displaylevel = 10
866 ** If @use_wildcard = 0 and the default sortorder is case-insensitive
867 ** dictionary sort order, use exact match: name = @configname to get row,
868 ** otherwise use wildcard match: name like "%" + @configname + "%".
871 if (@use_wildcard = 0 and @nocase = 1)
873 select @confignum = config,
877 from master.dbo.sysconfigures
878 where name = @configname
883 select @confignum = config,
887 from master.dbo.sysconfigures
888 where name like "%" + @configname + "%"
892 select @children = count(*)
893 from master.dbo.sysconfigures
894 where parent = @confignum
898 /* @@nestlevel is problem area if a sproc calls sp_configure */
899 /* could pass in another param when recursing */
902 /* reached a leaf, notify parent */
907 /* display the information of the config parameter */
908 select "Parameter Name" = convert(char(30), name),
909 "Default" = convert(char(11), space(11-char_length(
910 convert(varchar(11), defvalue))) +
911 convert(varchar(11), defvalue)),
912 "Memory Used" = convert(char(11), space(11-char_length(
913 convert(varchar(11), c.comment))) +
914 convert(varchar(11), c.comment)),
915 "Config Value" = convert(char(11), space(11-char_length(
916 isnull(b.value2, convert(char(32), b.value)))) +
917 isnull(b.value2, convert(char(32), b.value))),
918 "Run Value" = convert(char(11), space(11-char_length(
919 isnull(c.value2, convert(char(32), c.value)))) +
920 isnull(c.value2, convert(char(32), c.value)))
921 from master.dbo.sysconfigures b,
922 master.dbo.syscurconfigs c
925 and name like "%" + @configname + "%"
933 select @msg = "Group: " + @sysname
938 /* this poor guy has kids, so recurse to leaves */
939 declare config_curs cursor for
940 select config, name, parent
941 from master.dbo.sysconfigures
942 where parent = @parent
947 fetch config_curs into @sysconfig, @sysname, @sysparent
949 while (@@sqlstatus = 0)
952 execute @status = sp_configure @sysname
958 ** this guy has leaves as kids,
959 ** so print out the leaves with
960 ** display level <= @user_displaylevel
961 ** Note: If a config parameter has more than one
962 ** parent, the extra parents are stored in
965 create table #configure_temp (config int)
967 insert into #configure_temp
969 from master.dbo.sysconfigures a,
970 master.dbo.syscurconfigs b
972 display_level <= @user_displaylevel
975 and a.config = b.config
978 from master.dbo.syscurconfigs,
979 master.dbo.sysattributes
981 display_level <= @user_displaylevel
984 and object_type = 'CP'
985 and int_value = @parent
989 if exists (select * from #configure_temp)
991 select "Parameter Name" = convert(char(30), name),
992 "Default" = convert(char(11), space(11-char_length(
993 convert(varchar(11), defvalue))) +
994 convert(varchar(11), defvalue)),
995 "Memory Used" = convert(char(11), space(11-char_length(
996 convert(varchar(11), c.comment))) +
997 convert(varchar(11), c.comment)),
998 "Config Value" = convert(char(11),space(11-char_length(
999 isnull(b.value2, convert(char(32), b.value)))) +
1000 isnull(b.value2, convert(char(32), b.value))),
1001 "Run Value" = convert(char(11), space(11-char_length(
1002 isnull(c.value2, convert(char(32), c.value)))) +
1003 isnull(c.value2, convert(char(32), c.value)))
1004 from master.dbo.sysconfigures b,
1005 master.dbo.syscurconfigs c
1007 (select config from #configure_temp)
1008 and b.config = c.config
1012 drop table #configure_temp
1015 deallocate cursor config_curs
1022 ** this lucky guy has grandkids, so, continue
1024 fetch config_curs into
1025 @sysconfig, @sysname, @sysparent
1031 deallocate cursor config_curs
1037 IF OBJECT_ID('dbo.sp_configure') IS NOT NULL
1039 GRANT EXECUTE ON dbo.sp_configure TO public
1042 /* Procedure sp_dboption, owner dbo */
1047 /* Sccsid = "%Z% generic/sproc/%M% %I% %G%" */
1048 /* 4.8 1.1 06/14/90 sproc/src/a_values */
1051 ** Messages for "sp_dboption" 17420
1052 ** Use "langid" when looking at spt_values ???
1054 ** 17260, "Can't run %1! from within a transaction."
1055 ** 17420, "Settable database options."
1056 ** 17421, "No such database -- run sp_helpdb to list databases."
1057 ** 17422, "The 'master' database's options can not be changed."
1058 ** 17423, "Usage: sp_dboption [dbname, optname, {true | false}]"
1059 ** 17424, "Database option doesn't exist or can't be set by user."
1060 ** 17425, "Run sp_dboption with no parameters to see options."
1061 ** 17426, "Database option is not unique."
1062 ** 17428, "You must be in the 'master' database in order to change
1063 ** database options."
1064 ** 17429, "The database is currently in use -- 'read only' option
1066 ** 17430, "Run the CHECKPOINT command in the database that was changed."
1069 ** 17433, "Database option '%1!' turned ON for database '%2!'."
1070 ** 17434, "Database option '%1!' turned OFF for database '%2!'."
1071 ** 17289, "Set your curwrite to the hurdle of current database."
1072 ** 17436, "The 'single user' option is not valid for the 'tempdb'
1074 ** 17439, "You cannot turn on ''%1!' for '%2!' because it is an HA server
1075 ** that has been configured with the proxy_db option."
1078 create procedure sp_dboption
1079 @dbname varchar(30) = NULL, /* database name to change */
1080 @optname varchar(20) = NULL, /* option name to turn on/off */
1081 @optvalue varchar(10) = NULL /* true or false */
1084 declare @dbid int /* dbid of the database */
1085 declare @dbuid int /* id of the owner of the database */
1086 declare @statvalue smallint, /* number of option */
1087 @stattype char(2), /* status field flag */
1088 @statopt smallint, /* option mask, part 1 */
1089 @stat2opt smallint /* option mask, part 2 */
1090 declare @optcount int /* number of options like @optname */
1091 declare @success_msg varchar(255) /* success status message */
1092 declare @msg varchar(250)
1093 declare @sptlang int
1094 declare @true varchar(10)
1095 declare @false varchar(10)
1096 declare @whichone int /* which language? */
1097 declare @name varchar(30)
1098 declare @optmsgnum int /* identify one msgnum to compare */
1099 declare @msgcnt int /* count distinct dups */
1108 set transaction isolation level 1
1110 select @sptlang = @@langid, @whichone = 0
1115 select * from master.dbo.sysmessages where error
1116 between 17050 and 17069
1117 and langid = @@langid)
1123 ** If no @dbname given, just list the possible dboptions.
1124 ** Only certain status bits may be set or cleared.
1125 ** settable not settable
1126 ** ------------------------------ --------------------------
1127 ** allow select into/bulkcopy (4) don't recover (32)
1128 ** read only (1024) not recovered (256)
1129 ** dbo use only (2048) dbname has changed (16384)
1130 ** single user (4096)
1131 ** truncate log on checkpoint (8)
1132 ** no checkpoint on recovery (16)
1133 ** allow null (8192)
1134 ** ddl in tran (512)
1135 ** ALL SETTABLE OPTIONS (15900)
1136 ** abort xact on log full (1, type='D2')
1137 ** no space accounting (2, type='D2')
1138 ** auto identity(4, type='D2')
1139 ** identity in nonunique index(8, type='D2')
1140 ** auto identity unique index(64, type='D2')
1144 ** Look for the "settable options" mask in spt_values
1146 select @statopt = number
1147 from master.dbo.spt_values
1149 and name = "ALL SETTABLE OPTIONS"
1151 select @stat2opt = number
1152 from master.dbo.spt_values
1154 and name = "ALL SETTABLE OPTIONS"
1157 ** If we can't find the option masks, guess at them
1160 select @statopt = 4 | 8 | 16 | 512 | 1024 | 2048 | 4096 | 8192
1161 if @stat2opt is null
1162 select @stat2opt = 1 | 2 | 4 | 8 | 64
1167 ** 17420, "Settable database options."
1169 exec sp_getmessage 17420, @msg output
1173 select database_options = name
1174 from master.dbo.spt_values
1176 and number & @statopt = number
1177 and number & @statopt != @statopt)
1179 and number & @stat2opt = number
1180 and number & @stat2opt != @stat2opt))
1183 select database_options = name, convert(char(22), description)
1184 from master.dbo.spt_values, master.dbo.sysmessages
1186 and number & @statopt = number
1187 and number & @statopt != @statopt)
1189 and number & @stat2opt = number
1190 and number & @stat2opt != @stat2opt))
1192 and langid = @sptlang
1198 ** Verify the database name and get the @dbid and @dbuid
1200 select @dbid = dbid, @dbuid = suid
1201 from master.dbo.sysdatabases
1202 where name = @dbname
1205 ** If @dbname not found, say so and list the databases.
1210 ** 17421, "No such database -- run sp_helpdb to list databases."
1217 ** Only the Database Owner (DBO) or
1218 ** Accounts with SA role can execute it.
1219 ** Call proc_role() with the required SA role.
1221 if ((suser_id() != @dbuid) and (proc_role("sa_role") < 1))
1225 ** You can not change any of the options in master. If the user tries to
1226 ** do so tell them they can't.
1231 ** 17422, "The 'master' database's options can not be changed."
1238 ** Check remaining parameters.
1241 exec sp_getmessage 17431, @true out
1242 /* 17432, "false" */
1243 exec sp_getmessage 17432, @false out
1244 if @optname is NULL or lower(@optvalue) not in
1245 ("true", "false", @true, @false) or @optvalue is null
1248 ** 17423, "Usage: sp_dboption [dbname, optname, {true | false}]"
1255 ** Use @optname and try to find the right option.
1256 ** If there isn't just one, print appropriate diagnostics and return.
1258 select @optcount = count(*)
1259 from master.dbo.spt_values
1260 where name like "%" + @optname + "%"
1262 and number & @statopt = number)
1264 and number & @stat2opt = number))
1266 ** If more than one option like @optname, make sure they are not the same
1267 ** option ("trunc" and "trunc.", for example)
1271 select @optmsgnum = msgnum
1272 from master.dbo.spt_values
1273 where name like "%" + @optname + "%"
1275 and number & @statopt = number)
1277 and number & @stat2opt = number))
1279 select @msgcnt = count(msgnum)
1280 from master.dbo.spt_values
1281 where name like "%" + @optname + "%"
1283 and number & @statopt = number)
1285 and number & @stat2opt = number))
1286 and msgnum != @optmsgnum
1289 ** msgcnt of 0 indicates we really have just 1 unique dboption,
1290 ** probably due to alternate spelling.
1293 select @optcount = 1
1296 ** If no option, and alternate language is set, use other language
1298 if @optcount = 0 and @sptlang != 0
1300 select @optcount = count(*)
1301 from master.dbo.spt_values, master.dbo.sysmessages
1302 where description like "%" + @optname + "%"
1304 and number & @statopt = number)
1306 and number & @stat2opt = number))
1308 and langid = @sptlang
1309 select @whichone = 1
1311 ** If more than one option like @optname, make sure they are not the same
1312 ** option ("trunc" and "trunc.", for example)
1316 select @optmsgnum = msgnum
1317 from master.dbo.spt_values, master.dbo.sysmessages
1318 where description like "%" + @optname + "%"
1320 and number & @statopt = number)
1322 and number & @stat2opt = number))
1324 and langid = @sptlang
1326 select @msgcnt = count(msgnum)
1327 from master.dbo.spt_values, master.dbo.sysmessages
1328 where description like "%" + @optname + "%"
1330 and number & @statopt = number)
1332 and number & @stat2opt = number))
1334 and langid = @sptlang
1335 and msgnum != @optmsgnum
1338 ** msgcnt of 0 indicates we really have just 1 unique dboption,
1339 ** probably due to alternate spelling.
1342 select @optcount = 1
1347 ** If no option, show the user what the options are.
1352 ** 17424, "Database option doesn't exist or can't be set by user."
1357 ** 17425, "Run sp_dboption with no parameters to see options."
1359 exec sp_getmessage 17425, @msg output
1365 ** If more than one option like @optname, show the duplicates and return.
1370 ** 17426, "Database option is not unique."
1375 select duplicate_options = name
1376 from master.dbo.spt_values
1377 where name like "%" + @optname + "%"
1379 and number & @statopt = number)
1381 and number & @stat2opt = number))
1383 select duplicate_options = name, convert(char(22), description)
1384 from master.dbo.spt_values, master.dbo.sysmessages
1385 where (name like "%" + @optname + "%"
1386 or description like "%" + @optname + "%")
1388 and number & @statopt = number)
1390 and number & @stat2opt = number))
1392 and langid = @sptlang
1398 if db_name() != "master"
1401 ** 17428, "You must be in the 'master' database in order to change database options."
1408 ** User cannot set "tempdb" database in single user mode.
1410 select @statvalue = number
1411 from master.dbo.spt_values
1412 where name like "%" + @optname + "%"
1414 and number & @statopt = number)
1416 and number & @stat2opt = number))
1418 if (@dbid = 2) and (@statvalue = 4096)
1421 ** 17436, "The 'single user' option is not valid for the 'tempdb'
1429 ** If we're in a transaction, disallow this since it might make recovery
1435 ** 17260, "Can't run %1! from within a transaction."
1437 raiserror 17260, "sp_dboption"
1445 set transaction isolation level 1
1448 ** Get the number which is the bit value to set
1451 select @statvalue = number, @stattype = type, @success_msg = name
1452 from master.dbo.spt_values
1453 where name like "%" + @optname + "%"
1455 and number & @statopt = number)
1457 and number & @stat2opt = number))
1459 select @statvalue = number, @stattype = type, @success_msg = name
1460 from master.dbo.spt_values, master.dbo.sysmessages
1461 where description like "%" + @optname + "%"
1463 and number & @statopt = number)
1465 and number & @stat2opt = number))
1467 and langid = @sptlang
1470 ** We do not allow 'sybsecurity' to be set to 'single user' since,
1471 ** if auditing is enabled and we try to set 'sybsecurity' database to
1472 ** 'single user' then, the audit process is killed because audit process
1473 ** tries to do 'usedb' and it fails (look at utils/auditing.c).
1475 if (@dbname = "sybsecurity") and (@statvalue = 4096)
1478 ** 17435, "The 'single user' option is not valid for the
1479 ** 'sybsecurity' database.
1487 ** Now update sysdatabases.
1490 if lower(@optvalue) in ("true", @true)
1493 ** If this the option to make the database read only,
1494 ** we need to do some checking first.
1495 ** Unless it's the master db, no one can be using it.
1496 ** If it's the master db, only the SA may be using it.
1498 if (@statvalue = 1024) and (select count(*)
1499 from master.dbo.sysprocesses
1500 where dbid = @dbid) > 0
1503 ** 17429, "The database is currently in use -- 'read only' option disallowed."
1510 ** If this is the option to set 'abort tran on log full' to
1511 ** true for sybsecurit database, then don't allow.
1513 if (db_name(@dbid) = "sybsecurity"
1514 and @stattype = "D2" and @statvalue = 1)
1517 ** AUDIT_CHANGE: New error message needs to be reserved and
1518 ** the print statement needs to be removed.
1520 print "You cannot set 'abort tran on log full' to true for sybsecurity database."
1525 ** Disallow DDL IN TRAN
1526 ** if proxydb option is set (@@crthaproxy = 1)
1527 ** if this server is a HA server (@@cmpstate >= 0)
1529 if ((@statvalue = 512) and (@@crthaproxy = 1) and (@@cmpstate >= 0))
1532 ** Cannot set DDL_IN_TRAN option for HA servers
1533 ** configured with proxy_db option.
1535 select @name = db_name(@dbid)
1536 exec sp_getmessage 17439, @msg output
1537 print @msg, @success_msg, @name
1541 if (@stattype = "D")
1542 update master.dbo.sysdatabases
1543 set status = status | @statvalue
1546 update master.dbo.sysdatabases
1547 set status2 = status2 | @statvalue
1550 ** 17433, "Database option %1! turned ON for database %2!."
1552 exec sp_getmessage 17433, @msg output
1553 select @name = db_name(@dbid)
1554 print @msg, @success_msg, @name
1558 ** We want to turn it off.
1563 if (@stattype = "D")
1564 update master.dbo.sysdatabases
1565 set status = status & ~@statvalue
1568 update master.dbo.sysdatabases
1569 set status2 = status2 & ~@statvalue
1572 ** 17434, "Database option %1! turned OFF for database %2!."
1574 exec sp_getmessage 17434, @msg output
1575 select @name = db_name(@dbid)
1576 print @msg, @success_msg, @name
1580 ** Advise the user to run the CHECKPOINT command in the database that
1584 ** 17430, "Run the CHECKPOINT command in the database that was changed."
1586 exec sp_getmessage 17430, @msg output
1593 IF OBJECT_ID('dbo.sp_dboption') IS NOT NULL
1595 GRANT EXECUTE ON dbo.sp_dboption TO public
1598 /* Procedure sp_dbupgrade, owner dbo */
1603 /* Sccsid = "%Z% generic/sproc/%M% %I% %G%" */
1606 create procedure sp_dbupgrade
1614 set transaction isolation level 1
1617 ** Do the sysindexes column names update which is part of the 38 upgrade.
1618 ** The sysgams updates have already been taken care of by pg_gamalloc.
1620 print "Upgrading Sysindexes columns in the database"
1621 if not exists (select name from syscolumns where id = 2 and name = 'doampg')
1625 where id = 2 and name = 'dpages'
1628 where id = 2 and name = 'reserved'
1631 where id = 2 and name = 'used'
1634 where id = 2 and name = 'rows'
1637 /* The following updates are part of the 42 upgrade. */
1640 ** Tweak the Syscolumns entries for the Sysindexes table so that
1641 ** "soid" and "csid" replace half of "usagecnt".
1643 if not exists (select * from syscolumns where id = 2 and name = 'soid')
1647 set type = 52, length = 2, usertype = 6, offset = 42
1648 where id = 2 and colid = 13
1649 insert into syscolumns
1650 (id, number, colid, status, type, length, offset,
1651 usertype, cdefault, domain, name, printfmt)
1652 values (2, 0, 23, 0, 48, 1, 40, 5, 0, 0, 'soid', '')
1653 insert into syscolumns
1654 (id, number, colid, status, type, length, offset,
1655 usertype, cdefault, domain, name, printfmt)
1656 values (2, 0, 24, 0, 48, 1, 41, 5, 0, 0, 'csid', '')
1660 print "Adding new datatypes to the database."
1661 if exists (select * from systypes where name = 'text')
1663 delete systypes where name = 'text'
1665 insert systypes (uid, usertype, variable, allownulls, type, length,
1666 tdefault, domain, name, printfmt)
1667 values (1, 19, 0, 1, 35, 16, 0, 0, 'text', null)
1668 if exists (select * from systypes where name = 'image')
1670 delete systypes where name = 'image'
1672 insert systypes (uid, usertype, variable, allownulls, type, length,
1673 tdefault, domain, name, printfmt)
1674 values (1, 20, 0, 1, 34, 16, 0, 0, 'image', null)
1675 if exists (select * from systypes where name = 'timestamp')
1677 delete systypes where name = 'timestamp'
1679 insert systypes (uid, usertype, variable, allownulls, type, length,
1680 tdefault, domain, name, printfmt)
1681 values (1, 80, 0, 1, 37, 8, 0, 0, 'timestamp', null)
1682 if exists (select * from systypes where name = 'smallmoney')
1684 delete systypes where name = 'smallmoney'
1686 insert systypes (uid, usertype, variable, allownulls, type, length,
1687 tdefault, domain, name, printfmt)
1688 values (1, 21, 0, 1, 122, 4, 0, 0, 'smallmoney', null)
1689 if exists (select * from systypes where name = 'smalldatetime')
1691 delete systypes where name = 'smalldatetime'
1693 insert systypes (uid, usertype, variable, allownulls, type, length,
1694 tdefault, domain, name, printfmt)
1695 values (1, 22, 0, 1, 58, 4, 0, 0, 'smalldatetime', null)
1696 if exists (select * from systypes where name = 'real')
1698 delete systypes where name = 'real'
1700 insert systypes (uid, usertype, variable, allownulls, type, length,
1701 tdefault, domain, name, printfmt)
1702 values (1, 23, 0, 1, 59, 4, 0, 0, 'real', null)
1704 /* 4.9 user types for national character */
1705 if exists (select * from systypes where name = 'nchar')
1707 delete systypes where name = 'nchar'
1709 insert systypes (uid, usertype, variable, allownulls, type, length,
1710 tdefault, domain, name, printfmt )
1711 values (1, 24, 0, 1, 47, 255, 0, 0, 'nchar', null)
1713 if exists (select * from systypes where name = 'nvarchar')
1715 delete systypes where name = 'nvarchar'
1717 insert systypes (uid, usertype, variable, allownulls, type, length,
1718 tdefault, domain, name, printfmt)
1719 values (1, 25, 1, 1, 39, 255, 0, 0, 'nvarchar', null)
1721 if exists (select * from systypes where name = 'NULL')
1723 delete systypes where name = 'NULL'
1725 insert systypes (uid, usertype, variable, allownulls, type, length,
1726 tdefault, domain, name, printfmt)
1727 values (1, 0, 0, 1, 0, 0, 0, 0, 'NULL', null)
1729 /* 4.9 system table creation */
1730 print "Creating system catalog: sysusermessages and its indexes."
1731 if not exists (select * from sysobjects where name='sysusermessages')
1733 execute sp_configure 'allow updates', 1
1734 reconfigure with override
1738 create table sysusermessages(error int,uid smallint,
1739 description varchar(255), langid smallint null) lock allpages
1740 create clustered index csysusermessages
1741 on sysusermessages (error)
1742 create unique nonclustered index ncsysusermessages
1743 on sysusermessages (error, langid)
1747 execute sp_configure 'allow updates', 0
1748 reconfigure with override
1751 print "Shutting down SQL Server"
1758 /* Procedure sp_getmessage, owner dbo */
1764 /* generic/sproc/getmessage 14.2 4/25/91 */
1766 /* Messages from sysmessages
1767 ** 17200, "Message number must be greater than or equal to 17000."
1768 ** 17201, "'%1!' is not an official language name from Syslanguages."
1769 ** 17202, "Message number %1! does not exist in the %2! language."
1772 create procedure sp_getmessage
1774 @result varchar(255) output,
1775 @language varchar(30) = NULL
1778 declare @lang_id smallint
1779 declare @msg varchar(255)
1780 declare @returncode smallint
1787 set transaction isolation level 1
1790 ** Use default language if none specified,
1791 ** and initialize result
1793 select @lang_id = @@langid, @result = NULL
1795 /* Only retrieve external errors */
1796 if @message_num < 17000
1798 /* 17200 "Message number must be greater than or equal to 17000." */
1799 select @msg = description from master.dbo.sysmessages
1806 ** Check that language is valid.
1808 if @language is not NULL
1810 execute @returncode = sp_validlang @language
1813 /* Us_english is always valid */
1814 if @language != "us_english"
1817 ** 17201, "'%1!' is not an official language
1818 ** name from Syslanguages."
1820 select @msg = description from master.dbo.sysmessages
1822 and langid = @@langid
1824 /* Get english if the current language is missing */
1826 select @msg = description from master.dbo.sysmessages
1830 print @msg, @language
1834 /* set to us_english */
1835 select @lang_id = NULL
1839 select @lang_id = langid from master.dbo.syslanguages
1840 where @language = name
1844 /* The langid is assigned 0 since it gets its value from @@langid. */
1845 /* For us_english, we have to insert it as NULL and not 0, this is */
1846 /* to maintain compatibility with the current conventions */
1849 select @lang_id = NULL
1852 /* Get message from the proper place */
1853 /* System messages */
1854 if @message_num < 20000
1856 select @result = description from master.dbo.sysmessages
1857 where langid = @lang_id
1858 and error = @message_num
1860 /* Get english if the current language is missing */
1862 select @result = description from master.dbo.sysmessages
1863 where error = @message_num
1864 and (langid is NULL or langid =0)
1869 /* There is no proper alternate language for user messages */
1870 select @result = description from sysusermessages
1871 where langid = @lang_id
1872 and error = @message_num
1874 /* this is in here for compatibility with older revs which */
1875 /* by mistake used to add langid as 0 in sysusermessages */
1876 if @result is null and @lang_id is NULL
1877 select @result = description from sysusermessages
1878 where (langid = 0 or langid is NULL)
1879 and error = @message_num
1883 /* Warn the user if the message can't be found */
1886 /* 17202, "Message number %1! does not exist in the %2! language." */
1887 select @msg = description from master.dbo.sysmessages
1889 and langid = @@langid
1891 if @language is null
1892 select @language = @@language
1895 select @msg = "Message number %1! does not exist in the %2! language."
1897 print @msg, @message_num, @language
1906 IF OBJECT_ID('dbo.sp_getmessage') IS NOT NULL
1908 GRANT EXECUTE ON dbo.sp_getmessage TO public
1911 /* Procedure sp_loaddbupgrade, owner dbo */
1916 /* Sccsid = "%Z% generic/sproc/src/%M% %I% %G%" */
1918 create procedure sp_loaddbupgrade
1919 @databasename varchar(30),
1920 @devname varchar(30)
1929 set transaction isolation level 1
1933 /* The recovery which is part of load database will perform the upgrade */
1934 load database @databasename from @devname
1942 /* Procedure sp_procxmode, owner dbo */
1947 /* Sccsid = "%Z% generic/sproc/src/%M% %I% %G%" */
1950 ** 17756, "The execution of the stored procedure '%1!' in database
1951 ** '%2!' was aborted because there was an error in writing the
1952 ** replication log record."
1955 create procedure sp_procxmode
1956 @procname varchar(255) = null,
1957 @tranmode varchar(30) = null
1960 declare @uid smallint
1962 declare @msg varchar(250) /* message text */
1963 declare @dbname varchar(30)
1970 set transaction isolation level 1
1972 /* If either parameter is null we will be joining with a temporary table
1973 ** to convert transaction mode numbers (0, 1, 2) to strings ("Unchained",
1974 ** "Chained", "Any Mode").
1976 if ((@procname is null) or (@tranmode is null))
1978 create table #tranmode (intval integer, charval varchar(15))
1979 insert into #tranmode values(0, "Unchained")
1980 insert into #tranmode values(1, "Chained")
1981 insert into #tranmode values(2, "Any Mode")
1984 /* If the first parameter is null, we're to report the transaction-modes
1985 ** of every stored procedure in the current database.
1987 if (@procname is null)
1989 select "procedure name" = o.name, "user name" = user_name(o.uid),
1990 "transaction mode" = t.charval
1991 from sysobjects o, #tranmode t
1992 where ((o.type = "P") or (o.type = "XP")) and (t.intval = ((o.sysstat2 / 16) & 3))
1998 /* If only the second parameter is null, we're to report the
1999 ** transaction-mode of the specified stored procedure.
2001 if ((@procname is not null) and (@tranmode is null))
2003 if (not exists (select name from sysobjects
2004 where ((type = "P") or (type = "XP")) and
2005 (name = @procname)))
2008 ** Force an error message, since we haven't
2009 ** installed sp_getmessage yet.
2011 dbcc update_tmode(@procname, "Chained")
2014 select "procedure name" = o.name, "user name" = user_name(o.uid),
2015 "transaction mode" = t.charval
2016 from sysobjects o, #tranmode t
2017 where ((o.type = "P") or (o.type = "XP")) and (@procname = o.name) and
2018 (t.intval = ((o.sysstat2 / 16) & 3))
2023 /* If neither parameter is null, we're to set the transaction-mode
2024 ** of the specified procedure to the specified value.
2026 if ((@procname is not null) and (@tranmode is not null))
2028 /* Start the transaction to log the execution of this procedure.
2030 ** IMPORTANT: The name "rs_logexec is significant and is used by
2031 ** Replication Server
2033 begin transaction rs_logexec
2036 ** Update transaction-mode in both sysobjects and DES.
2038 dbcc update_tmode(@procname, @tranmode)
2040 /* If dbcc update_tmode returned an error, return
2045 rollback transaction rs_logexec
2050 ** Write the log record to replicate this invocation
2051 ** of the stored procedure.
2056 ** 17756, "The execution of the stored procedure '%1!'
2057 ** in database '%2!' was aborted because there
2058 ** was an error in writing the replication log
2061 select @dbname = db_name()
2062 raiserror 17756, "sp_procxmode", @dbname
2064 rollback transaction rs_logexec
2074 IF OBJECT_ID('dbo.sp_procxmode') IS NOT NULL
2076 GRANT EXECUTE ON dbo.sp_procxmode TO public
2079 /* Procedure sp_prtsybsysmsgs, owner dbo */
2084 /* Sccsid = "%Z% generic/sproc/%M% %I% %G%" */
2087 ** This procedure is needed to extract messages for the batch that creates
2088 ** the sybsystemprocs database. When return parameters are used in an execute
2089 ** statement that is a part of a SQL batch, the return values are printed
2090 ** with a heading before subsequent statements in the batch are executed.
2091 ** These headings could be confusing to a user that is looking at the results
2092 ** of the batch. Hence we print the message in a stored procedure
2095 create procedure sp_prtsybsysmsgs
2096 @i int, @size int = NULL, @size2 int = NULL
2099 declare @msg varchar(250)
2101 exec sp_getmessage @i, @msg out
2102 print @msg, @size, @size2
2106 /* Procedure sp_validlang, owner dbo */
2111 /* Sccsid = "%Z% generic/sproc/src/%M% %I% %G%" */
2112 /* 4.8 1.1 06/14/90 sproc/src/serveroption */
2113 create procedure sp_validlang
2123 set transaction isolation level 1
2125 /* Check to see if this language is in Syslanguages. */
2127 from master.dbo.syslanguages
2136 IF OBJECT_ID('dbo.sp_validlang') IS NOT NULL
2138 GRANT EXECUTE ON dbo.sp_validlang TO public
2144 /* No triggers found. */
2146 /** New testing for views and procedures **/
2149 -- View: vs_xdp_data
2152 CREATE VIEW vs_xdp_data
2155 x.discoveryProtocol AS discovery_protocol,
2156 dbo.inet_ntoa( remoteIpAddr ) AS remote_ip_address,
2157 x.remoteSysDescr AS remote_sys_descr,
2158 x.remoteSysName AS remote_sys_name,
2159 x.remoteInterfaceName AS remote_interface_name,
2160 x.remotePlatform AS remote_platform,
2161 x.localInterfaceName AS local_interface_name,
2162 x.class_name AS category,
2163 e.dateSeen AS date_seen,
2164 m.user_id AS user_access
2172 x.discoveryEvent_id = e.id AND
2173 e.adminIpAddr = d.ipaddr AND
2174 ast.foreign_asset_id2 = d.device_id AND
2175 ast.acl_id = m.acl_id
2179 -- Procedure: Tx_B_Get_Vlan
2182 create procedure Tx_B_Get_Vlan
2186 @Managed_Element_Id bigint
2193 SELECT VlanName, VlanNumber, VlanStatus
2196 JOIN Device D on V.fk_device = D.Id
2197 JOIN Asset A on A.foreign_asset_id2 = D.device_id
2198 JOIN M_Access_Control MA on MA.acl_id = A.Acl_id
2199 where D.Id = @Device_Id and V.fk_managed_element = @Managed_Element_Id and MA.User_Id = @User_Access
2206 -- Function: inet_ntoa
2209 CREATE FUNCTION [dbo].inet_ntoa
2224 @octet1 = ( @ipLong / 16777216 ) & 255,
2225 @octet2 = ( @ipLong / 65536 ) & 255,
2226 @octet3 = ( @ipLong / 256 ) & 255,
2227 @octet4 = @ipLong & 255
2231 CONVERT( VARCHAR(5), @octet1 ) +
2233 CONVERT( VARCHAR(5), @octet2 ) +
2235 CONVERT( VARCHAR(5), @octet3 ) +
2237 CONVERT( VARCHAR(5), @octet4 )