Showing posts with label transaction. Show all posts
Showing posts with label transaction. Show all posts

Friday, March 30, 2012

How to get the transaction in the trigger?

Hi,
I want to be able to recuperate in my Trigger the transaction that is
'triggering' the Trigger. So i want to be able to have the SQL-statement
that was/will be performed on the table.
Does anybody knows how to do this? any help would be really appreicated!
thanks a lot in advance,
Pieter
See if this helps:
http://vyaskn.tripod.com/tracking_sq...y_triggers.htm
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"DraguVaso" <pietercoucke@.hotmail.com> wrote in message
news:%23hlysmzRFHA.1392@.TK2MSFTNGP10.phx.gbl...
Hi,
I want to be able to recuperate in my Trigger the transaction that is
'triggering' the Trigger. So i want to be able to have the SQL-statement
that was/will be performed on the table.
Does anybody knows how to do this? any help would be really appreicated!
thanks a lot in advance,
Pieter
|||Thanks!! You're great!!
I modied it a little bit so it puts everything in a table.
just one more thing: is there a way to know in the trigger itself if it was
an insert/update or delete-statement (when having 1 trigger that handles all
like in your exemple).
Thanks a lot!
Pieter
"Narayana Vyas Kondreddi" <answer_me@.hotmail.com> wrote in message
news:umvn0uzRFHA.3944@.TK2MSFTNGP10.phx.gbl...
> See if this helps:
> http://vyaskn.tripod.com/tracking_sq...y_triggers.htm
> --
> HTH,
> Vyas, MVP (SQL Server)
> SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
>
> "DraguVaso" <pietercoucke@.hotmail.com> wrote in message
> news:%23hlysmzRFHA.1392@.TK2MSFTNGP10.phx.gbl...
> Hi,
> I want to be able to recuperate in my Trigger the transaction that is
> 'triggering' the Trigger. So i want to be able to have the SQL-statement
> that was/will be performed on the table.
> Does anybody knows how to do this? any help would be really appreicated!
> thanks a lot in advance,
> Pieter
>
>
|||Just check the whether you have >= 1 rows in the inserted and deleted tables.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"DraguVaso" <pietercoucke@.hotmail.com> wrote in message
news:e2%23oHE0RFHA.3076@.TK2MSFTNGP14.phx.gbl...
> Thanks!! You're great!!
> I modied it a little bit so it puts everything in a table.
> just one more thing: is there a way to know in the trigger itself if it was
> an insert/update or delete-statement (when having 1 trigger that handles all
> like in your exemple).
> Thanks a lot!
> Pieter
> "Narayana Vyas Kondreddi" <answer_me@.hotmail.com> wrote in message
> news:umvn0uzRFHA.3944@.TK2MSFTNGP10.phx.gbl...
>
|||See if the following helps:
IF EXISTS(SELECT 1 FROM inserted) AND (NOT EXISTS (SELECT 1 FROM deleted))
BEGIN
PRINT 'INSERT'
--Perform necessary processing
END
ELSE
IF EXISTS (SELECT 1 FROM deleted) AND (NOT EXISTS (SELECT 1 FROM inserted))
BEGIN
PRINT 'DELETE'
--Perform necessary processing
END
ELSE
IF EXISTS(SELECT 1 FROM inserted) AND (EXISTS(SELECT 1 FROM deleted))
BEGIN
PRINT 'UPDATE'
--Perform necessary processing
END
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"DraguVaso" <pietercoucke@.hotmail.com> wrote in message
news:e2%23oHE0RFHA.3076@.TK2MSFTNGP14.phx.gbl...
Thanks!! You're great!!
I modied it a little bit so it puts everything in a table.
just one more thing: is there a way to know in the trigger itself if it was
an insert/update or delete-statement (when having 1 trigger that handles all
like in your exemple).
Thanks a lot!
Pieter
"Narayana Vyas Kondreddi" <answer_me@.hotmail.com> wrote in message
news:umvn0uzRFHA.3944@.TK2MSFTNGP10.phx.gbl...
> See if this helps:
> http://vyaskn.tripod.com/tracking_sq...y_triggers.htm
> --
> HTH,
> Vyas, MVP (SQL Server)
> SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
>
> "DraguVaso" <pietercoucke@.hotmail.com> wrote in message
> news:%23hlysmzRFHA.1392@.TK2MSFTNGP10.phx.gbl...
> Hi,
> I want to be able to recuperate in my Trigger the transaction that is
> 'triggering' the Trigger. So i want to be able to have the SQL-statement
> that was/will be performed on the table.
> Does anybody knows how to do this? any help would be really appreicated!
> thanks a lot in advance,
> Pieter
>
>
|||Thanks, it works great like that.
Unless users perform an Update/Delete that doesn't update or delete a record
at all, but I don't need that records neither. Instead it's maybe better
form e, hehe :-)
thanks a lot for your work! You helped me a lot with this problem!
"Narayana Vyas Kondreddi" <answer_me@.hotmail.com> wrote in message
news:e3y6io0RFHA.1500@.TK2MSFTNGP09.phx.gbl...
> See if the following helps:
> IF EXISTS(SELECT 1 FROM inserted) AND (NOT EXISTS (SELECT 1 FROM deleted))
> BEGIN
> PRINT 'INSERT'
> --Perform necessary processing
> END
> ELSE
> IF EXISTS (SELECT 1 FROM deleted) AND (NOT EXISTS (SELECT 1 FROM
inserted))
> BEGIN
> PRINT 'DELETE'
> --Perform necessary processing
> END
> ELSE
> IF EXISTS(SELECT 1 FROM inserted) AND (EXISTS(SELECT 1 FROM deleted))
> BEGIN
> PRINT 'UPDATE'
> --Perform necessary processing
> END
>
> --
> HTH,
> Vyas, MVP (SQL Server)
> SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
>
> "DraguVaso" <pietercoucke@.hotmail.com> wrote in message
> news:e2%23oHE0RFHA.3076@.TK2MSFTNGP14.phx.gbl...
> Thanks!! You're great!!
> I modied it a little bit so it puts everything in a table.
> just one more thing: is there a way to know in the trigger itself if it
was
> an insert/update or delete-statement (when having 1 trigger that handles
all
> like in your exemple).
> Thanks a lot!
> Pieter
> "Narayana Vyas Kondreddi" <answer_me@.hotmail.com> wrote in message
> news:umvn0uzRFHA.3944@.TK2MSFTNGP10.phx.gbl...
>
>

How to get the transaction in the trigger?

Hi,
I want to be able to recuperate in my Trigger the transaction that is
'triggering' the Trigger. So i want to be able to have the SQL-statement
that was/will be performed on the table.
Does anybody knows how to do this? any help would be really appreicated!
thanks a lot in advance,
PieterSee if this helps:
http://vyaskn.tripod.com/tracking_s...by_triggers.htm
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"DraguVaso" <pietercoucke@.hotmail.com> wrote in message
news:%23hlysmzRFHA.1392@.TK2MSFTNGP10.phx.gbl...
Hi,
I want to be able to recuperate in my Trigger the transaction that is
'triggering' the Trigger. So i want to be able to have the SQL-statement
that was/will be performed on the table.
Does anybody knows how to do this? any help would be really appreicated!
thanks a lot in advance,
Pieter|||Thanks!! You're great!!
I modied it a little bit so it puts everything in a table.
just one more thing: is there a way to know in the trigger itself if it was
an insert/update or delete-statement (when having 1 trigger that handles all
like in your exemple).
Thanks a lot!
Pieter
"Narayana Vyas Kondreddi" <answer_me@.hotmail.com> wrote in message
news:umvn0uzRFHA.3944@.TK2MSFTNGP10.phx.gbl...
> See if this helps:
> http://vyaskn.tripod.com/tracking_s...by_triggers.htm
> --
> HTH,
> Vyas, MVP (SQL Server)
> SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
>
> "DraguVaso" <pietercoucke@.hotmail.com> wrote in message
> news:%23hlysmzRFHA.1392@.TK2MSFTNGP10.phx.gbl...
> Hi,
> I want to be able to recuperate in my Trigger the transaction that is
> 'triggering' the Trigger. So i want to be able to have the SQL-statement
> that was/will be performed on the table.
> Does anybody knows how to do this? any help would be really appreicated!
> thanks a lot in advance,
> Pieter
>
>|||Just check the whether you have >= 1 rows in the inserted and deleted tables
.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"DraguVaso" <pietercoucke@.hotmail.com> wrote in message
news:e2%23oHE0RFHA.3076@.TK2MSFTNGP14.phx.gbl...
> Thanks!! You're great!!
> I modied it a little bit so it puts everything in a table.
> just one more thing: is there a way to know in the trigger itself if it wa
s
> an insert/update or delete-statement (when having 1 trigger that handles a
ll
> like in your exemple).
> Thanks a lot!
> Pieter
> "Narayana Vyas Kondreddi" <answer_me@.hotmail.com> wrote in message
> news:umvn0uzRFHA.3944@.TK2MSFTNGP10.phx.gbl...
>|||See if the following helps:
IF EXISTS(SELECT 1 FROM inserted) AND (NOT EXISTS (SELECT 1 FROM deleted))
BEGIN
PRINT 'INSERT'
--Perform necessary processing
END
ELSE
IF EXISTS (SELECT 1 FROM deleted) AND (NOT EXISTS (SELECT 1 FROM inserted))
BEGIN
PRINT 'DELETE'
--Perform necessary processing
END
ELSE
IF EXISTS(SELECT 1 FROM inserted) AND (EXISTS(SELECT 1 FROM deleted))
BEGIN
PRINT 'UPDATE'
--Perform necessary processing
END
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"DraguVaso" <pietercoucke@.hotmail.com> wrote in message
news:e2%23oHE0RFHA.3076@.TK2MSFTNGP14.phx.gbl...
Thanks!! You're great!!
I modied it a little bit so it puts everything in a table.
just one more thing: is there a way to know in the trigger itself if it was
an insert/update or delete-statement (when having 1 trigger that handles all
like in your exemple).
Thanks a lot!
Pieter
"Narayana Vyas Kondreddi" <answer_me@.hotmail.com> wrote in message
news:umvn0uzRFHA.3944@.TK2MSFTNGP10.phx.gbl...
> See if this helps:
> http://vyaskn.tripod.com/tracking_s...by_triggers.htm
> --
> HTH,
> Vyas, MVP (SQL Server)
> SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
>
> "DraguVaso" <pietercoucke@.hotmail.com> wrote in message
> news:%23hlysmzRFHA.1392@.TK2MSFTNGP10.phx.gbl...
> Hi,
> I want to be able to recuperate in my Trigger the transaction that is
> 'triggering' the Trigger. So i want to be able to have the SQL-statement
> that was/will be performed on the table.
> Does anybody knows how to do this? any help would be really appreicated!
> thanks a lot in advance,
> Pieter
>
>|||Thanks, it works great like that.
Unless users perform an Update/Delete that doesn't update or delete a record
at all, but I don't need that records neither. Instead it's maybe better
form e, hehe :-)
thanks a lot for your work! You helped me a lot with this problem!
"Narayana Vyas Kondreddi" <answer_me@.hotmail.com> wrote in message
news:e3y6io0RFHA.1500@.TK2MSFTNGP09.phx.gbl...
> See if the following helps:
> IF EXISTS(SELECT 1 FROM inserted) AND (NOT EXISTS (SELECT 1 FROM deleted))
> BEGIN
> PRINT 'INSERT'
> --Perform necessary processing
> END
> ELSE
> IF EXISTS (SELECT 1 FROM deleted) AND (NOT EXISTS (SELECT 1 FROM
inserted))
> BEGIN
> PRINT 'DELETE'
> --Perform necessary processing
> END
> ELSE
> IF EXISTS(SELECT 1 FROM inserted) AND (EXISTS(SELECT 1 FROM deleted))
> BEGIN
> PRINT 'UPDATE'
> --Perform necessary processing
> END
>
> --
> HTH,
> Vyas, MVP (SQL Server)
> SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
>
> "DraguVaso" <pietercoucke@.hotmail.com> wrote in message
> news:e2%23oHE0RFHA.3076@.TK2MSFTNGP14.phx.gbl...
> Thanks!! You're great!!
> I modied it a little bit so it puts everything in a table.
> just one more thing: is there a way to know in the trigger itself if it
was
> an insert/update or delete-statement (when having 1 trigger that handles
all
> like in your exemple).
> Thanks a lot!
> Pieter
> "Narayana Vyas Kondreddi" <answer_me@.hotmail.com> wrote in message
> news:umvn0uzRFHA.3944@.TK2MSFTNGP10.phx.gbl...
>
>

How to get the transaction in the trigger?

Hi,
I want to be able to recuperate in my Trigger the transaction that is
'triggering' the Trigger. So i want to be able to have the SQL-statement
that was/will be performed on the table.
Does anybody knows how to do this? any help would be really appreicated!
thanks a lot in advance,
PieterSee if this helps:
http://vyaskn.tripod.com/tracking_sql_statements_by_triggers.htm
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"DraguVaso" <pietercoucke@.hotmail.com> wrote in message
news:%23hlysmzRFHA.1392@.TK2MSFTNGP10.phx.gbl...
Hi,
I want to be able to recuperate in my Trigger the transaction that is
'triggering' the Trigger. So i want to be able to have the SQL-statement
that was/will be performed on the table.
Does anybody knows how to do this? any help would be really appreicated!
thanks a lot in advance,
Pieter|||Thanks!! You're great!!
I modied it a little bit so it puts everything in a table.
just one more thing: is there a way to know in the trigger itself if it was
an insert/update or delete-statement (when having 1 trigger that handles all
like in your exemple).
Thanks a lot!
Pieter
"Narayana Vyas Kondreddi" <answer_me@.hotmail.com> wrote in message
news:umvn0uzRFHA.3944@.TK2MSFTNGP10.phx.gbl...
> See if this helps:
> http://vyaskn.tripod.com/tracking_sql_statements_by_triggers.htm
> --
> HTH,
> Vyas, MVP (SQL Server)
> SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
>
> "DraguVaso" <pietercoucke@.hotmail.com> wrote in message
> news:%23hlysmzRFHA.1392@.TK2MSFTNGP10.phx.gbl...
> Hi,
> I want to be able to recuperate in my Trigger the transaction that is
> 'triggering' the Trigger. So i want to be able to have the SQL-statement
> that was/will be performed on the table.
> Does anybody knows how to do this? any help would be really appreicated!
> thanks a lot in advance,
> Pieter
>
>|||Just check the whether you have >= 1 rows in the inserted and deleted tables.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"DraguVaso" <pietercoucke@.hotmail.com> wrote in message
news:e2%23oHE0RFHA.3076@.TK2MSFTNGP14.phx.gbl...
> Thanks!! You're great!!
> I modied it a little bit so it puts everything in a table.
> just one more thing: is there a way to know in the trigger itself if it was
> an insert/update or delete-statement (when having 1 trigger that handles all
> like in your exemple).
> Thanks a lot!
> Pieter
> "Narayana Vyas Kondreddi" <answer_me@.hotmail.com> wrote in message
> news:umvn0uzRFHA.3944@.TK2MSFTNGP10.phx.gbl...
>> See if this helps:
>> http://vyaskn.tripod.com/tracking_sql_statements_by_triggers.htm
>> --
>> HTH,
>> Vyas, MVP (SQL Server)
>> SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
>>
>> "DraguVaso" <pietercoucke@.hotmail.com> wrote in message
>> news:%23hlysmzRFHA.1392@.TK2MSFTNGP10.phx.gbl...
>> Hi,
>> I want to be able to recuperate in my Trigger the transaction that is
>> 'triggering' the Trigger. So i want to be able to have the SQL-statement
>> that was/will be performed on the table.
>> Does anybody knows how to do this? any help would be really appreicated!
>> thanks a lot in advance,
>> Pieter
>>
>|||See if the following helps:
IF EXISTS(SELECT 1 FROM inserted) AND (NOT EXISTS (SELECT 1 FROM deleted))
BEGIN
PRINT 'INSERT'
--Perform necessary processing
END
ELSE
IF EXISTS (SELECT 1 FROM deleted) AND (NOT EXISTS (SELECT 1 FROM inserted))
BEGIN
PRINT 'DELETE'
--Perform necessary processing
END
ELSE
IF EXISTS(SELECT 1 FROM inserted) AND (EXISTS(SELECT 1 FROM deleted))
BEGIN
PRINT 'UPDATE'
--Perform necessary processing
END
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"DraguVaso" <pietercoucke@.hotmail.com> wrote in message
news:e2%23oHE0RFHA.3076@.TK2MSFTNGP14.phx.gbl...
Thanks!! You're great!!
I modied it a little bit so it puts everything in a table.
just one more thing: is there a way to know in the trigger itself if it was
an insert/update or delete-statement (when having 1 trigger that handles all
like in your exemple).
Thanks a lot!
Pieter
"Narayana Vyas Kondreddi" <answer_me@.hotmail.com> wrote in message
news:umvn0uzRFHA.3944@.TK2MSFTNGP10.phx.gbl...
> See if this helps:
> http://vyaskn.tripod.com/tracking_sql_statements_by_triggers.htm
> --
> HTH,
> Vyas, MVP (SQL Server)
> SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
>
> "DraguVaso" <pietercoucke@.hotmail.com> wrote in message
> news:%23hlysmzRFHA.1392@.TK2MSFTNGP10.phx.gbl...
> Hi,
> I want to be able to recuperate in my Trigger the transaction that is
> 'triggering' the Trigger. So i want to be able to have the SQL-statement
> that was/will be performed on the table.
> Does anybody knows how to do this? any help would be really appreicated!
> thanks a lot in advance,
> Pieter
>
>|||Thanks, it works great like that.
Unless users perform an Update/Delete that doesn't update or delete a record
at all, but I don't need that records neither. Instead it's maybe better
form e, hehe :-)
thanks a lot for your work! You helped me a lot with this problem!
"Narayana Vyas Kondreddi" <answer_me@.hotmail.com> wrote in message
news:e3y6io0RFHA.1500@.TK2MSFTNGP09.phx.gbl...
> See if the following helps:
> IF EXISTS(SELECT 1 FROM inserted) AND (NOT EXISTS (SELECT 1 FROM deleted))
> BEGIN
> PRINT 'INSERT'
> --Perform necessary processing
> END
> ELSE
> IF EXISTS (SELECT 1 FROM deleted) AND (NOT EXISTS (SELECT 1 FROM
inserted))
> BEGIN
> PRINT 'DELETE'
> --Perform necessary processing
> END
> ELSE
> IF EXISTS(SELECT 1 FROM inserted) AND (EXISTS(SELECT 1 FROM deleted))
> BEGIN
> PRINT 'UPDATE'
> --Perform necessary processing
> END
>
> --
> HTH,
> Vyas, MVP (SQL Server)
> SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
>
> "DraguVaso" <pietercoucke@.hotmail.com> wrote in message
> news:e2%23oHE0RFHA.3076@.TK2MSFTNGP14.phx.gbl...
> Thanks!! You're great!!
> I modied it a little bit so it puts everything in a table.
> just one more thing: is there a way to know in the trigger itself if it
was
> an insert/update or delete-statement (when having 1 trigger that handles
all
> like in your exemple).
> Thanks a lot!
> Pieter
> "Narayana Vyas Kondreddi" <answer_me@.hotmail.com> wrote in message
> news:umvn0uzRFHA.3944@.TK2MSFTNGP10.phx.gbl...
> > See if this helps:
> > http://vyaskn.tripod.com/tracking_sql_statements_by_triggers.htm
> > --
> > HTH,
> > Vyas, MVP (SQL Server)
> > SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
> >
> >
> > "DraguVaso" <pietercoucke@.hotmail.com> wrote in message
> > news:%23hlysmzRFHA.1392@.TK2MSFTNGP10.phx.gbl...
> > Hi,
> >
> > I want to be able to recuperate in my Trigger the transaction that is
> > 'triggering' the Trigger. So i want to be able to have the SQL-statement
> > that was/will be performed on the table.
> >
> > Does anybody knows how to do this? any help would be really appreicated!
> >
> > thanks a lot in advance,
> >
> > Pieter
> >
> >
> >
>
>

Wednesday, March 7, 2012

How to get new sql server logs without restart SQL server (not SQL transaction log)

hi
I'm using SQL 2000 SP4 on Win2003 Server
By default, when we restart the SQL server, the new "sql server logs" will
be created, my question is, how to achieve the same result by NOT restart
the SQL server
Thanks a lot> By default, when we restart the SQL server, the new "sql server logs" will
> be created, my question is, how to achieve the same result by NOT restart
> the SQL server
EXEC sp_cycle_errorlog
--
Hope this helps.
Dan Guzman
SQL Server MVP
"gbkhor" <gbkhor@.time.net.my> wrote in message
news:uJSGIj4UIHA.6060@.TK2MSFTNGP05.phx.gbl...
> hi
> I'm using SQL 2000 SP4 on Win2003 Server
> By default, when we restart the SQL server, the new "sql server logs" will
> be created, my question is, how to achieve the same result by NOT restart
> the SQL server
> Thanks a lot
>|||Thanks Dan, it work well
"Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
news:1E79D060-BADE-4703-9E23-EB3D374F27F9@.microsoft.com...
>> By default, when we restart the SQL server, the new "sql server logs"
>> will be created, my question is, how to achieve the same result by NOT
>> restart the SQL server
> EXEC sp_cycle_errorlog
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "gbkhor" <gbkhor@.time.net.my> wrote in message
> news:uJSGIj4UIHA.6060@.TK2MSFTNGP05.phx.gbl...
>> hi
>> I'm using SQL 2000 SP4 on Win2003 Server
>> By default, when we restart the SQL server, the new "sql server logs"
>> will be created, my question is, how to achieve the same result by NOT
>> restart the SQL server
>> Thanks a lot
>

How to get new sql server logs without restart SQL server (not SQL transaction log)

hi
I'm using SQL 2000 SP4 on Win2003 Server
By default, when we restart the SQL server, the new "sql server logs" will
be created, my question is, how to achieve the same result by NOT restart
the SQL server
Thanks a lot
> By default, when we restart the SQL server, the new "sql server logs" will
> be created, my question is, how to achieve the same result by NOT restart
> the SQL server
EXEC sp_cycle_errorlog
Hope this helps.
Dan Guzman
SQL Server MVP
"gbkhor" <gbkhor@.time.net.my> wrote in message
news:uJSGIj4UIHA.6060@.TK2MSFTNGP05.phx.gbl...
> hi
> I'm using SQL 2000 SP4 on Win2003 Server
> By default, when we restart the SQL server, the new "sql server logs" will
> be created, my question is, how to achieve the same result by NOT restart
> the SQL server
> Thanks a lot
>
|||Thanks Dan, it work well
"Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
news:1E79D060-BADE-4703-9E23-EB3D374F27F9@.microsoft.com...
> EXEC sp_cycle_errorlog
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "gbkhor" <gbkhor@.time.net.my> wrote in message
> news:uJSGIj4UIHA.6060@.TK2MSFTNGP05.phx.gbl...
>

Friday, February 24, 2012

How to get last lsn for my DB

I need to restore multiple set file from a transaction log backup.
To know from which position of this file starting my restore, i need to know
the last lsn point restored on my DB.
while @.id_start < @.id_stop
begin
set @.id_start = @.id_start + 1
RESTORE LOG [MYDB]
FROM DISK = N'Y:\MYDB_LOG'
WITH STANDBY = 'C:\Programmi\Microsoft SQL Server\MSSQL\UNDO_MYDB.ldf',
FILE = @.id_start
if @.@.error > 0
begin
set @.id_stop = 0
BREAK
end
end
I need to know the @.id_start to begin the restore for all backup set missing
.
ThanksHi
RESTORE DATABASE test FROM disk = 'd:\db.bak' WITH FILE = 1, norecovery
RESTORE LOG test FROM disk = 'd:\log.bak' WITH FILE = 1, norecovery
RESTORE LOG test FROM disk = 'd:\log.bak' WITH FILE = 2, norecovery
RESTORE LOG test FROM disk = 'd:\log.bak' WITH FILE = 3, recovery
"checcouno" <checcouno@.discussions.microsoft.com> wrote in message
news:7BF739FD-E00E-4C13-ABDF-75CC564F31CD@.microsoft.com...
> I need to restore multiple set file from a transaction log backup.
> To know from which position of this file starting my restore, i need to
know
> the last lsn point restored on my DB.
>
> while @.id_start < @.id_stop
> begin
> set @.id_start = @.id_start + 1
> RESTORE LOG [MYDB]
> FROM DISK = N'Y:\MYDB_LOG'
> WITH STANDBY = 'C:\Programmi\Microsoft SQL
Server\MSSQL\UNDO_MYDB.ldf',
> FILE = @.id_start
> if @.@.error > 0
> begin
> set @.id_stop = 0
> BREAK
> end
> end
> I need to know the @.id_start to begin the restore for all backup set
missing.
> Thanks