March 16, 2020 at 12:00 am
Comments posted to this topic are about the item Backing Up Some Log
March 16, 2020 at 1:46 am
Sorry, Steve... there is no correct answer here.
--Jeff Moden
Change is inevitable... Change for the better is not.
March 16, 2020 at 5:01 am
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
March 16, 2020 at 8:05 am
This would only work if a database with the variable name would exist...
There is no correct answer here.
Louis.
March 16, 2020 at 9:06 am
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
March 16, 2020 at 9:41 am
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!
March 16, 2020 at 1:46 pm
What they said ^
March 16, 2020 at 2:45 pm
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
March 16, 2020 at 3:08 pm
Ah, sorry. It was working, then I added the file name change. I've adapted the question and this should award back points.
March 16, 2020 at 4:00 pm
My favorite timestamp is Select Convert(nVarchar(8), SYSDATETIME(), 112) + '_' + Replace(Convert(nVarchar(8), SYSDATETIME(), 114), ':', '')
March 17, 2020 at 4:10 am
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