Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 High Availability (2005)
 redirct to mirror server by T-SQL

Author  Topic 

kernelvn
Starting Member

4 Posts

Posted - 2007-05-10 : 05:06:38
I use T-SQL to flush database server (principal role) but not find out the way to hanlde failover occur for my demo

Can you help???

Here is my code (without success) wishing any suggetion
declare @ConnectA as smallint
declare @id as bigint

:setvar Database2Mirror Mirroring
:setvar partnername partnera

set @ConnectA = 1
set @id = 1

while (1 > 0) begin
set @id = @id + 1
begin try
:connect $(partnername)
use Mirroring;
print 'Insert in to servername: ';
insert into dbo.UserInfor (IncreaseNumber) values (@id);
end try
begin catch
w
if (@ConnectA = 1)
:setvar partnername partnerb
set @connectA = 2
else
:setvar partnername partnera
set @connectA = 1
:connect $(partnername)
continue
end catch

end

   

- Advertisement -