use master
go

sp_configure "allow updates", 1
go

/* 
** Updates to sysattributes
*/

delete sysattributes 
	where class = 0 and attribute = 0 
	and object_type = 'AC' and object = 4 
insert sysattributes (class, attribute, object_type, object, 
			object_info1, char_value) 
  		values (0, 0, 'AC', 4, NULL, 'config manager')
go

delete sysattributes 
	where class = 0 and attribute = 1 
	and object_type = 'A' and object = 4 
	and object_info1 = 0 
insert sysattributes (class, attribute, object_type, object, 
			object_info1, char_value) 
  		values (0, 1, 'A', 4, 0, 'user config level')
go

delete sysattributes 
	where class = 0 and attribute = 1 
	and object_type = 'A' and object = 4 
	and object_info1 = 1 
insert sysattributes (class, attribute, object_type, object, 
			object_info1, char_value) 
  		values (0, 1, 'A', 4, 1, 'config parameter parent')
go

delete sysattributes 
	where class = 0 and attribute = 0 
	and object_type = 'AC' and object = 5 
insert sysattributes (class, attribute, object_type, object, 
			object_info1, char_value) 
  		values (0, 0, 'AC', 5, NULL, 'lock strategy')
go

delete sysattributes 
	where class = 0 and attribute = 1 
	and object_type = 'A' and object = 5 
	and object_info1 = 0 
insert sysattributes (class, attribute, object_type, object, 
			object_info1, char_value) 
  		values (0, 1, 'A', 5, 0, 'Lock promotion')
go

delete sysattributes
	where class = 4
	and attribute = 1
	and object_type = 'CP'
go
insert sysattributes (class, attribute, object_type, object,
			object_info1, int_value)
	values (4, 1, 'CP', 103, 1, 7)
insert sysattributes (class, attribute, object_type, object,
			object_info1, int_value)
	values (4, 1, 'CP', 104, 1, 7)
insert sysattributes (class, attribute, object_type, object,
			object_info1, int_value)
	values (4, 1, 'CP', 104, 2, 4)
insert sysattributes (class, attribute, object_type, object,
			object_info1, int_value)
	values (4, 1, 'CP', 105, 1, 7)
insert sysattributes (class, attribute, object_type, object,
			object_info1, int_value)
	values (4, 1, 'CP', 106, 1, 7)
insert sysattributes (class, attribute, object_type, object,
			object_info1, int_value)
	values (4, 1, 'CP', 107, 1, 7)
insert sysattributes (class, attribute, object_type, object,
			object_info1, int_value)
	values (4, 1, 'CP', 116, 1, 7)
insert sysattributes (class, attribute, object_type, object,
			object_info1, int_value)
	values (4, 1, 'CP', 117, 1, 3)
insert sysattributes (class, attribute, object_type, object,
			object_info1, int_value)
	values (4, 1, 'CP', 126, 1, 7)
insert sysattributes (class, attribute, object_type, object,
			object_info1, int_value)
	values (4, 1, 'CP', 134, 1, 7)
insert sysattributes (class, attribute, object_type, object,
			object_info1, int_value)
	values (4, 1, 'CP', 136, 1, 7)
insert sysattributes (class, attribute, object_type, object,
			object_info1, int_value)
	values (4, 1, 'CP', 137, 1, 7)
insert sysattributes (class, attribute, object_type, object,
			object_info1, int_value)
	values (4, 1, 'CP', 137, 2, 8)
insert sysattributes (class, attribute, object_type, object,
			object_info1, int_value)
	values (4, 1, 'CP', 138, 1, 16)
insert sysattributes (class, attribute, object_type, object,
			object_info1, int_value)
	values (4, 1, 'CP', 157, 1, 9)
insert sysattributes (class, attribute, object_type, object,
			object_info1, int_value)
	values (4, 1, 'CP', 174, 1, 16)
insert sysattributes (class, attribute, object_type, object,
			object_info1, int_value)
	values (4, 1, 'CP', 212, 1, 7)
go

/*
** Add the sp_us_mesg stored procedure
*/
if exists (select * from sysobjects where name = 'sp_us_mesg' and type = 'P')
begin
	drop procedure sp_us_mesg
end
go

/* CREATE PROCEDURE SP_US_MESG */
create procedure sp_us_mesg
	@error_number int,
	@severity_number int,
	@message_text varchar(255)
as
declare @retval int
declare @fmtbuf varchar(255)
set nocount on
select @retval = 0
select @retval = (select 1 
		     from sysmessages 
			where error = @error_number and langid is NULL
		  )
/* message is not available so insert it. */
if (@message_text != NULL)
	begin
	if (@retval = 1) 
		begin
		select @fmtbuf = (select "Modifying Message: " 
			+ convert(varchar(8),@error_number) + " Severity: " 
			+ convert(varchar(8),@severity_number))
		print @fmtbuf
		begin tran
		update sysmessages 
			set error=@error_number,
			severity=@severity_number,
			dlevel=2,	/* dlevel is always 2 */
			description=@message_text,
			langid=NULL	/* messages are shipped in English. */
			where langid is NULL and error=@error_number
		commit tran
		end
	else
		begin
		select @fmtbuf = "Adding Message: "
			+ convert(varchar(8),@error_number) + " Severity: "
			+ convert(varchar(8),@severity_number)
		print @fmtbuf
		begin tran
		insert sysmessages values (
			@error_number,
			@severity_number,
			2,		/* dlevel is always 2 */
			@message_text,
			NULL,
			NULL)		/* messages are shipped in English. */
		commit tran
		end
	end
go

exec sp_us_mesg 801, 20,
"Process %d tried to remove resource lock it doesn't hold on buffer 0x%\
lx - %S_PAGE in cache %s."
go

exec sp_us_mesg 1624, 18,
"Warning: Errors occured while initializing thresholds on tempdb. Tryin\
g to continue the startup. Thresholds might not be active on tempdb."
go

exec sp_us_mesg 2788, 16, NULL
go

exec sp_us_mesg 4204, 17,
"Unable to continue logged version of DUMP TRANsaction. Please free up \
some space in database %d or use the NO_LOG option."
go

exec sp_us_mesg 4226, 16,
"Logged DUMP TRANSACTION cannot run in database %.*s, because that data\
bases's log version (%d) disagrees with the SQL Server's log version (\
%d); use DUMP TRANSACTION WITH NO_LOG. Versions will agree once ONLINE\
 DATABASE has run."
go

exec sp_us_mesg 4227, 17,
"No space left on master database. Creating user objects in master data\
base is not recommended."
go

exec sp_us_mesg 4228, 17,
"No space left in database id '%d'. Use alter database to increase size\
 of database. Dedicated log segment recommended for user databases."
go

exec sp_us_mesg 5839, 16,
"The value of 'max network packet size', '%ld', must be greater than or\
 equal to the value of the 'default network packet size', '%ld'."
go

exec sp_us_mesg 5881, 16,
	"The value of 'default network packet size', '%ld', must be less than o\
r equal to the value of the 'max network packet size', '%ld'."
go

exec sp_us_mesg 5891, 16,
"Named cache '%s' has been configured too small. The minimum size of a \
named cache is %d Kilobytes."
go

exec sp_us_mesg 10109, 16,
"The value of the parameter '%s' is '%d'. The value should be between %\
d and %d."
go


drop procedure sp_us_mesg
go

sp_configure "allow updates", 0
go

