Backing Up Some Log

  • Comments posted to this topic are about the item Backing Up Some Log

  • Sorry, Steve... there is no correct answer here.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • I'm afraid none of the answers are correct.

    as it stands, it would only work if there was a database with the date as part of the name, which would write to a static file as given

     

  • This would only work if a database with the variable name would exist...

    There is no correct answer here.

    Louis.

  • I agree the backup statement is incorrect.

     

    This will work:

    DECLARE @d NVARCHAR(MAX) = 'AdventureWorks2012'

    DECLARE @n NVARCHAR(MAX)

    SELECT @n = @d + '_' + CAST(CAST(SYSDATETIME() AS DATE) AS nvarchar(20)) + '.trn'

    BACKUP LOG @d TO DISK = @n

     

     

  • Read the question, and thought: I'm not going to touch this with a ten-foot pole, until it has been reviewed. The discussion bears this out...

    On a side note: It used to be that you couldn't see the discussion at all until you'd answered. Since the site overhaul, sometimes the answer is given in the short bits of the discussion on the question page. That's a bit naff!


    Just because you're right doesn't mean everybody else is wrong.

  • Jeff Moden wrote:

    Sorry, Steve... there is no correct answer here.

    I agree.

  • What they said ^

     

  • yeah question was a mess. I did pick "cannot be a variable" even though I'm pretty sure I used a variable for the backup command before.

     

    Not a big deal for me, I miss most of them LOL

     

  • Ah, sorry. It was working, then I added the file name change. I've adapted the question and this should award back points.

  • My favorite timestamp is Select Convert(nVarchar(8), SYSDATETIME(), 112) + '_' + Replace(Convert(nVarchar(8), SYSDATETIME(), 114), ':', '')

  • Reading through the discussion makes me glad i was offline most of yesterday.

    Nice question, thanks Steve

    ____________________________________________
    Space, the final frontier? not any more...
    All limits henceforth are self-imposed.
    “libera tute vulgaris ex”

Viewing 12 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic. Login to reply