use master
go

sp_configure "allow updates", 1
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 680, 20,
"Attempt to extend the log in database '%.*s' failed due to an internal\
 error. The returned status was %d."
go

exec sp_us_mesg 710, 20,
"Memory request for %d bytes is too small."
go

exec sp_us_mesg 857, 16,
"Command Failed: Cannot bind or unbind database '%S_DBID' to or from a \
cache because it is currently in use. Retry the command once all users\
 have stopped using the database."
go

exec sp_us_mesg 1287, 16,
"Freelock transfer block size (%d) cannot be more than half the number \
of freelocks allowed per engine (%d). To increase the number of freelo\
cks per engine to allow this change please increase maximum engine fre\
elocks to %d."
go

exec sp_us_mesg 1288, 16,
"Setting maximum engine freelocks to %d allows only %d freelocks per en\
gine. This value cannot be less than twice the value of freelock trans\
fer block size. Please reduce freelock transfer block size to %d and r\
eattempt this command."
go

exec sp_us_mesg 2789, 16, NULL
go

exec sp_us_mesg 2790, 16,
"Setting maximum online engines to %d causes number of engine freelocks\
 (%d) to fall below half the value of freelock transfer block size (%d\
). Please increase maximum engine freelocks to %d and reattempt this c\
ommand."
go

exec sp_us_mesg 3016, 17,
"DUMP DATABASE for '%S_DBID' cannot continue because of insufficient lo\
g space. Free some log space with DUMP TRANSACTION or turn off replica\
tion."
go

exec sp_us_mesg 3244, 20,
"%s failed for database '%S_DBID' with an internal transaction logging \
system failure; returned error code is %ld."
go

exec sp_us_mesg 3471, 10,
"Database '%.*s' can not be brought online because it has replicated ta\
bles that have not been completely transferred. It will come online au\
tomatically after replication is complete."
go

exec sp_us_mesg 3738, 16,
"The object '%.*s' of type %S_MSG does not have any indices."
go

exec sp_us_mesg 4621, 10,
"Warning. All permissions except CREATE DATABASE are granted/revoked. O\
nly System Administrator can grant/revoke CREATE DATABASE permission."
go

exec sp_us_mesg 4622, 10,
"Some or all of the specified privileges were not revoked because, they\
 were not granted, or they were granted by some other user."
go

exec sp_us_mesg 5152, 16,
"DISK REFIT failed. Either the database is corrupted or the value of th\
e VSTART parameter supplied to DISK INIT and DISK REINIT were differen\
t."
go

exec sp_us_mesg 5807, 16,
"The new load file has different size %s for the cache %s. Cache size i\
s static, not allowed to change during run time."
go

exec sp_us_mesg 5808, 16,
"The new load file has different cache type for the cache %s. Cache typ\
e is static, not allowed to change during run time."
go

exec sp_us_mesg 5809, 16,
"Less memory moved than requested in cache %s cache. Requested size = %\
d kb from pool %d, actual memory moved = %d kb."
go

exec sp_us_mesg 5810, 16,
"new (%d) buffer pool of size %d for cache %s is being created"
go

exec sp_us_mesg 5811, 16,
"The new load file does not have the cache %s definition. Cache type, s\
ize and number of caches should match the running values. Use sp_cache\
config to determine the running value"
go

exec sp_us_mesg 5812, 16,
"The new load file has %d caches defined against running %d cache defin\
itions.Cache type, size and number of caches should match the running \
values. Use sp_cacheconfig to determine the running value."
go

exec sp_us_mesg 5813, 16,
"The new load file has duplicate %s cache definitions, caches should be\
 uniqueue."
go

exec sp_us_mesg 5861, 16,
"The 'total memory', '%ld', is not enough to change the parameter '%s' \
to '%ld'."
go

exec sp_us_mesg 5870, 16,
"An invalid buffer size of %dk was encounterd in cache %s. Valid buffer\
 sizes for caches are powers of 2 between %dk and %dk inclusive."
go

exec sp_us_mesg 5875, 16,
"The cache type for the default data cache cannot be modified."
go

exec sp_us_mesg 5894, 16,
"Configuration Error: Duplicate pool size definition of '%s' for Named \
Cache '%s'."
go

exec sp_us_mesg 5895, 16,
"Configuration Error: Duplicate wash size definition of '%s' for Named \
Cache '%s'."
go

exec sp_us_mesg 5896, 16, NULL
go

exec sp_us_mesg 5897, 16, NULL
go

exec sp_us_mesg 5898, 10,
"WARNING!!! %dK buffer pool has been deleted. The log I/O size for the \
following data bases have been set to %dk. You must change the log I/O\
 size to an existing pool size."
go

exec sp_us_mesg 5899, 16,
"The value of the 'total memory' parameter (%ld) defined in the configu\
ration file is not high enough to set the other parameter values speci\
fied in the configuration file."
go

exec sp_us_mesg 6404, 18,
"Process %d in database '%.*s' was aborted. The transaction was rolled \
back, but an ENDXACT record was not written, probably because the log \
is full."
go

exec sp_us_mesg 7142, 16,
"The text pointer %s refers to a TEXT/IMAGE page that has been allocate\
d to a different row. This occurred because the original row was updat\
ed or deleted during an internal deadlock avoidance manuever."
go

exec sp_us_mesg 7375, 15,
"SELECT INTO cannot be specified with isolation level clause."
go

exec sp_us_mesg 7376, 15,
"Select in a CREATE VIEW cannot be specified with isolation level claus\
e."
go

exec sp_us_mesg 7377, 15,
"SELECT INSERT cannot be specified with isolation level clause."
go

exec sp_us_mesg 7387, 15,
"The maximum number of parameters in a dynamic SQL statement is %d."
go

exec sp_us_mesg 7388, 16,
"An aggregate of an aggregate produces a scalar value. Any further nest\
ing of aggregates has no effect. Remove the aggregates beyond level tw\
o."
go

exec sp_us_mesg 7389, 16,
"A HAVING clause with aggregates of different levels is not allowed."
go

exec sp_us_mesg 7975, 20,
"System catalog entrie(s) for Object %ld, Database %ld are corrupted."
go

exec sp_us_mesg 7976, 16,
"Object %ld in database %ld does not have any TEXT/IMAGE data."
go

exec sp_us_mesg 7977, 16,
"First page %ld and Root page %ld are not same."
go

exec sp_us_mesg 7978, 20,
"One or more text chain(s) for object %ld in database %ld is corrupt."
go

exec sp_us_mesg 7979, 16,
"Text chain linkage corrupted for Page %ld of Object %ld."
go

exec sp_us_mesg 7980, 16,
"Unreferenced text chain found for page %ld, nextpage %ld, prevpage %ld\
."
go

exec sp_us_mesg 8203, 26,
"Expected to find the descriptor for object %d in database %d in %s sta\
te."
go

exec sp_us_mesg 9122, 21,
"The log transfer process lost its connection to the LTM for database '\
%.*s'. Once the LTM re-establishes the connection, replication will co\
ntinue with no data loss."
go

exec sp_us_mesg 9148, 20,
"Replication server could not send log records for log version change p\
rocessing in database '%.*s' because the log processing functions retu\
rned internal error %d."
go

exec sp_us_mesg 9524, 16,
"SELECT is not allowed in a dynamic EXECUTE IMMEDIATE statement. This S\
ELECT may have been part of a stored procedure or a trigger."
go

exec sp_us_mesg 9525, 16,
"Attempt to update or delete a row in the table '%.*s' failed as the cu\
rsor '%.*s' does not point to a row in the table. This can happen when\
 the table is an inner member of an outer join and no row was returned\
 from this table in the last fetch."
go

exec sp_us_mesg 9526, 16,
"The positioned delete/update operation is not allowed with cursor '%.*\
s'. You may be referring the cursor in a dynamically prepared statemen\
t."
go

exec sp_us_mesg 9926, 16,
"This option has been converted to the configuration parameter '%s'. Us\
e 'sp_configure' to set it."
go

exec sp_us_mesg 9927, 16,
"This option requries a table name as the third parameter. Use 'sp_conf\
igure '%s'' to set the option serverwide."
go

exec sp_us_mesg 9928, 16,
"This option has been disabled. Use 'sp_poolconfig' instead."
go

exec sp_us_mesg 10215, 10,
"There have been %d scan fixups and %d matching search argument fixups \
for this cursor."
go

exec sp_us_mesg 10216, 10,
"The cursor is read only because it is referring to a fake table."
go

drop procedure sp_us_mesg
go

sp_configure "allow updates", 0
go

