Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_dbmmonitorMSgetthelatestlsn

 

Stored procedure was used in SQL 2005 to create a mirror. This procedure is removed in SQL 2008.




Syntax
create procedure sys.sp_dbmmonitorMSgetthelatestlsn 	
	@database_name			sysname,
	@end_of_log_lsn		numeric(25,0)=null output
as
begin
	set nocount on
	if (is_srvrolemember(N'sysadmin') <> 1 )
        begin
			raiserror(21089, 16, 1)
			return 1
		end
	if @database_name is null
	begin
		return 2
	end

	declare @str			char(64),
			@file			bigint,
			@file_size		int,
			@array			bigint,
			@array_size		int,
			@slot			int,
			@command		nvarchar(400)

	
    -- Check if the database specified exists

    if not exists (select * from master.sys.databases where name = @database_name)
    begin
        return 2
    end

	set @command = N'dbcc dbtable(' + CONVERT (nvarchar, DB_ID(@database_name)) + N') with tableresults, no_infomsgs'

	declare @temp table(parentObject nvarchar(255),Object nvarchar(255),field nvarchar(255),value nvarchar(255))
									-- TO DO: get correct values from SteveLi
									-- DONE: They are all nvarchar(255)
	insert into @temp exec( @command )																			
	select @str = value from @temp where field=N'm_flushLSN';
	
	set @file_size = charindex(N':', @str)
	set @file = cast( LEFT( @str, @file_size - 1) as bigint)
	set @array_size = charindex(N':', @str, @file_size + 1)
	set @array = cast( substring( @str, @file_size + 1, @array_size - @file_size - 1) as bigint)
	set @slot = cast( substring( @str, @array_size + 1, charindex(N' ', @str, @array_size + 1) - @array_size ) as int)
	set @end_of_log_lsn = @file * 1000000000000000 + @array * 100000 + @slot
	-- make sure @slot < MAX_SHORT (1024 * 64)
	-- check to make sure tht file and array are < 4 Gig.
	if (@end_of_log_lsn < 1000000000000000 or @slot >= 65536 or @file >= 4294967296 or @array >= 4294967296)
	begin
		set @end_of_log_lsn = null
		return 3	-- return a single error code.
	end
	return 0
end

 
Last revision
See also

  sp_dbmmonitorupdate (Procedure)
       



News

  Query a named instance
Sybase+ASE+silent+install
SQL 2008 R2
Deprecated procedures in SQL2008
Reporting Services item-level role definitions
Create all your missing indexes
Converting datetime field
Start MSSQL Server Profiler at time
Replicating MSSQL Server views
Exploring Microsoft Sharepoint
The OLE DB provider "SQLNCLI10" for linked server indicates.
Mobile solar charger
Oracle to SQL Server replication
Cannot insert the value NULL into column
Undocumented Microsoft SQL Server 2008
VMware
Zoekmachine optimalisatie
SQL Servers hidden objects
FckEditor
Flash in Ajax
De hype die AJAX heet
Barcode scannen
MySQL; Gratis, makkelijk en snel!
PHP
sIFR; de combinatie tussen HTML en Flash